bootstrap icon indicating copy to clipboard operation
bootstrap copied to clipboard

Starting example contains an unclosed tag

Open therealprof opened this issue 13 years ago • 15 comments

In your getting started section you mention the following minimum line to get started:

However this should read:

instead

therealprof avatar Jan 20 '13 17:01 therealprof

Bootstrap uses HTML5, not XHTML, so it's fine as-is. See https://developer.mozilla.org/en-US/docs/HTML/Element/link

cvrebert avatar Jan 20 '13 18:01 cvrebert

Wouldn't it make sense to also be XHTML compliant?

therealprof avatar Jan 21 '13 09:01 therealprof

XHTML != HTML5 in many many ways. The official HTML5 has single tag items as <example stuff="thing"> where XHTML requires the closing /. XHTML is a derivative of XML, while HTML5 is kind of its own thing.

hawkowl avatar Jan 21 '13 10:01 hawkowl

I get that but I really do not see any benefit in not properly closing tags only because HTML5 doesn't require you to do it.

therealprof avatar Jan 21 '13 12:01 therealprof

Except there is no 'properly closing tags' in HTML5. You only need to 'properly close tags' in XHTML. If I remember correctly, the concept of self closing tags doesn't exist in HTML5, and it only works to be backwards compatible with XHTML, where it was first introduced. This was so that XHTML could be parsed by XML parsers, or something silly like that.

hawkowl avatar Jan 21 '13 12:01 hawkowl

That would be a step backward. The benefits is for all developer to get rid of the headache for old browser compatibility XD ie. To use your word today I really do not see any benefit to still using XHTML, even ie9 support most of the html5 features.

boulox avatar Jan 21 '13 12:01 boulox

So far nobody has mentioned a real drawback of being XML compliant, even if HTML5 doesn't require it. But there're many advantages in doing so like better tool support and the ability to validate the code and better parsing stability in browsers. If you really wanted to screw XML compatibility (and browser compatibility) hard I'd have a lot of even better ideas how to achieve that...

therealprof avatar Jan 21 '13 14:01 therealprof

The drawback is that it's not HTML5 compliant. As per the spec, http://www.w3.org/html/wg/drafts/html/master/single-page.html#void-elements - "Raw text, RCDATA, and normal elements have a start tag to indicate where they begin, and an end tag to indicate where they end. The start and end tags of certain normal elements can be omitted, as described later. Those that cannot be omitted must not be omitted. Void elements only have a start tag; end tags must not be specified for void elements. Foreign elements must either have a start tag and an end tag, or a start tag that is marked as self-closing, in which case they must not have an end tag."

<link> is a void element, as detailed in the link cvrebert posted. That means that it /only/ has a start tag. Normal elements have a start and an end tag. The spec says the only things allowed to have self closing tags are 'foreign elements' which it defines as "Elements from the MathML namespace and the SVG namespace", which this is not.

In short, the drawback of being XML compliant is that you're not then HTML5 compliant. As HTML5 is not parsed by XML parsers, there is no benefit to being compliant with it, and the tools that parse HTML5 are designed with void elements in mind.

hawkowl avatar Jan 22 '13 07:01 hawkowl

You're reading the specs wrong. It clearly says that foreign elements must be properly ended or be made self-closing, it does absolutely not say that on the other hand it is forbidden to make non-foreign elements self-closing.

"In short, the drawback of being XML compliant is that you're not then HTML5 compliant"

That might be as well true (I honestly don't know), but in this particular case you're wrong.

"As HTML5 is not parsed by XML parsers, there is no benefit to being compliant with it, and the tools that parse HTML5 are designed with void elements in mind."

That assumption is not correct. Many browsers contain more than just one parser and/or parsers with many special cases in the code to work around some of the brokenness and ambiguities in HTML. I don't know of a single fully working HTML5 checker (even the W3C validator is still "experimental") while there're many XML tools around that can be used to at least check the syntactic correctness. As a matter of fact: VIM is the reason why I opened this ticket because it complained about the link tag and many of my other tools would, too.

therealprof avatar Jan 22 '13 08:01 therealprof

Seems I was wrong, the "/" is optional. Bootstrap's documentation still uses perfectly valid HTML5, so there's no reason to change it - maybe you should fix/update your tools? A quick github search says that there's a HTML5 vim config here ( https://github.com/othree/html5.vim ) - maybe try that then?

hawkowl avatar Jan 22 '13 08:01 hawkowl

I will continue to use valid XML instead because that's what I'll be using everyday anyhow.

What I don't get: If there's a easy way to have HTML5 that is also XML compliant; why don't use it? Or would you like to have a patch/pull request from me?

therealprof avatar Jan 22 '13 08:01 therealprof

@therealprof: It's worth noting that neither of Bootstrap's actual core maintainers have commented on this issue yet. Everyone so far is "just" another user like yourself.

cvrebert avatar Jan 22 '13 09:01 cvrebert

@therealprof: I think the only way to fix this would be to change the HTML5 specs to require />. If valid HTML5 wrecks your editor's highlighting, then you need to fix your editor, because otherwise it'll choke if you have to edit someone else's (perfectly valid) HTML5 code, like in this instance.

And yeah, I'm not a Bootstrap maintainer, just commenting.

hawkowl avatar Jan 22 '13 09:01 hawkowl

@hawkowl: It doesn't wreck highlighting. The problem is simply that there're many tools for XML and close to nil tools for non-XML HTML5. I prefer to use XML tools for HTML5 syntax and structure validation rather than using no tools at all.

therealprof avatar Jan 22 '13 09:01 therealprof

Trailing slashes are optional with an HTML5 doctype. We won't be adding them.

mdo avatar Jan 31 '13 01:01 mdo