why
and not
?

前端 未结 13 961
天涯浪人
天涯浪人 2020-12-29 05:29

This is one of those things that you read once, say \"aha!\" and then forget. Exactly my case.

Why is the line-break tag in xhtml preferentially written with a space

相关标签:
13条回答
  • 2020-12-29 05:43

    Both <br/> and <br /> are correct. The reason that <br /> came about in the first place was to support older browsers that didn't understand the new <br/> syntax. It's really kind of a hack where the / is interpreted as an attribute with no value and ignored.

    0 讨论(0)
  • 2020-12-29 05:43

    Both are correct, and both will be accepted by web browsers. You may as well save yourself the extra character, and use <br/>

    0 讨论(0)
  • 2020-12-29 05:43

    Both are correct.

    0 讨论(0)
  • 2020-12-29 05:44

    <br /> is valid (old) HTML, while <br/> is not. If you are serving your XHTML as XML, it doesn't matter. If you are serving it as text/html, then it needs to be valid HTML in addition to being valid XHTML. (Why serve XHTML as HTML? Because IE doesn't understand XHTML as XML, and because no major browser will start rendering XHTML mid-way through downloading the text, but they will do that to HTML. My blog appears to load slowly not because the site is slow, but because the browser won't start rendering the page until everything has been fetched. I hate browsers.)

    0 讨论(0)
  • 2020-12-29 05:44

    Either will work just fine. Assuming you are asking for evangelical reasons, I prefer <br/>

    0 讨论(0)
  • 2020-12-29 05:46

    w3c specifies this as the grammar:

    EmptyElemTag       ::=      '<' Name (S Attribute)* S? '/>'
    

    That means open bracket, a name, a number of (space and attribute) tokens, an optional space, a slash, and an end tag. According to this, both are correct.

    0 讨论(0)
提交回复
热议问题