Home > Software design >  What is the exact role of "inline" after the src here?
What is the exact role of "inline" after the src here?

Time:05-20

Usually, a script tag would look something like

<script src="/scripts/color.js"></script>

But I came across the one below

<script src="/scripts/color.js" inline></script>

So, what purpose is "inline" supposed to serve now?

CodePudding user response:

The inline attribute is not a valid attribute for the <script> tag. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script for the list of valid attributes.

Maybe the person who wrote this code thought about "inline script", which usually means writing the code directly in the HTML:

<script>
  // javascript goes here
</script>

CodePudding user response:

There is no attribute named inline anywhere in HTML.

It is most likely either an error or something that should be represented by a data-* attribute.

  • Related