Reputation: 173
Our CMS outputs linebreaks as <br></br>
(stupid, i know, but syntactically corrent(?))
This translates to <br><br>
in chrome and IE10 and to <br></br><br></br>
in Firefox.
All browsers shows it as two linebreaks.
Why are not <br></br>
translated like <br />
or just <br>
, is there something i can do
to make browser interpret <br></br>
as just one linebreak?
Upvotes: 3
Views: 191
Reputation: 24712
To answer your question... seeing as your CMS seems to output this abomination, if you need a quick fix...
Fiddle - http://jsfiddle.net/P6bDp/
Bonus CSS selector list - http://net.tutsplus.com/tutorials/html-css-techniques/the-30-css-selectors-you-must-memorize/
CSS
br + br {display: none;}
This will eliminate the second <br>
and leave a single line break. Fix that CMS though :)
Upvotes: 2
Reputation: 3262
It's defined by the HTML5 specifications: http://www.w3.org/TR/html5/syntax.html#parsing-main-inbody (search the text An end tag whose tag name is "br"
in the page).
If your document is parsed as an HTML document, each closing br
tag will be always parsed as if it was an opening tag (and creates an element with no content). But if you parse your document as an XHTML document a <br></br>
sequence will produce the same DOM tree as the <br/>
tag. To have your document parsed as an XHTML document, you have to send it with the application/xhtml+xml
mime type.
More details are available in the specifications: http://www.w3.org/TR/html5/introduction.html#html-vs-xhtml; http://www.w3.org/TR/html5/the-xhtml-syntax.html.
Upvotes: 3
Reputation: 1981
hey <br></br>
is not syntactically correct, you must use it as <br/>
(look at the slash). its inline element so no need to close like other elements. it closes itself
Upvotes: 1