You can clearly see line breaks not working inside Chrome here.
Unless I’m doing it wrong.
The text highlight should stop before
It’s not dong that in Chrome.
<span>Some randm text text text text<br/> Some randm text text text text<br/> Some randm text text text text</span></p>
which element is the background colour applied to?
Also, keep in mind that
<br> tags are generally considered bad practice.
Chrome just highlights the whitespace on the
The line break is working in both browsers, that’s the only rule of the game the browsers have to follow.
He highlighted the text by selecting it with the mouse, no background color
Oh right. I doubt the spec covers that! This is a very strange thing to worry about.
<br> whitespace, and firefox doesn’t?
Is that what you mean?
No, I may have not worded that correctly.
Chrome is allowing the whitespace node between the
<br> and the word
Some to be highlighted
You should see the same results in both browser if you do this
And btw, you can drop the closing slash and just use
Still occurring in Chrome:
<span>Some randm text text text text<br/>Some randm text text text text<br/>Some randm text text text text</span></p>
Browsers should consider a
<br> as a line break. It is an empty element and isn’t so much something that displays as it is an “instruction”.
Because the code example is misusing the
<br> you can’t really expect browsers to have a “standard” to follow because there is none for the way it is being misused.
How would I be misusing it?
Is there a right way to do it?
Can I ask why your concerned how the text looks when it’s highlighted? In what scenario would this ever matter?
You are using it to coerce inline elements to display more like block level elements.
As per the specs…
br elements must be used only for line breaks that are actually part of the content, as in poems or addresses.
The following example is correct usage of the
42 Wallaby Way<br>
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.