1

Can script tags in HTML be closed by simply using:

<script src="https://abc.js"/>

Or do I have to close this script tag like so:

<script src="https://abc.js"></script>

The reason I ask is because in sublime text 3 i have a highlighting problem that is slightly annoying. For example:

Indented with Tags

Yet when i remove the tag and self close it by "/>" you can see the horrible background highlighting issue goes away.

No indentation but highlighting disappears on line 1

I understand that a separate closing script tag is the standard way to close tags but why is it causing a change of font colour and background highlighting issue.

P.S. in the image it isn't shown very well but in contrast to the rest of the background, the whole line is highlighted a different colour and I cant seem to solve it.

Dan
  • 11
  • 1
  • 2
    Possible duplicate of [Why don't self-closing script tags work?](http://stackoverflow.com/questions/69913/why-dont-self-closing-script-tags-work) – bashaus Oct 11 '15 at 18:43
  • Self closing tags work if your file is served up as XHTML (MIME type application/xhtml+xml). However, they are not recommended, except for void elements. – Mr Lister Oct 11 '15 at 20:13
  • Anyway, I'm not sure why your screenshots show two different highlightings for self-closed and start+end tags. Unless the editor is using different highlighting for another reason? Current line; bookmark; part of selection etc. – Mr Lister Oct 11 '15 at 20:16
  • Ah okay. The highlighting is only caused by the indentation and by including tags. This may be the wrong place to be asking this question, its just strange that it applies when i include different tags. Ill try the sublime forum. Thanks for your help regardless. – Dan Oct 11 '15 at 21:02

0 Answers0