Is the following valid HTML?
As an HTML element I can\'t see why it wouldn\'t be, but I don\'t think I\'ve eve
Yes, is valid.
Specification tells that br
accepts global and event attributes, and class
is a global one.
Note that if you target HTML4 and below, there's an specific attribute for br
named clear
, which defines where to put the new line, as stated here, but now is deprecated and unless your DOCTYPE lets you, you should not use it anymore.
It does come handy when you want to omit the linebreak.e.g in a Headline when having a responsive layout and certain breakpoints.
It is valid in HTML 4.01, because the class
attribute is allowed for the br element. It is also valid in HTML5 in HTML serialization, because the class
attribute is allowed for all elements. It is not valid XHTML without a matching </br>
.
Yes, it's valid statement. you could use something like.
<br style="height: 100px; margin-top: 10000px;">
But instead using div element is recommended.
One application I can think off is adding using it with pseudo-elements, such as :before
or :after
, for instance adding some text beneath a horizotal line:
hr.something:after { content: "Some text" }
Yes you can, from the w3c specification : http://dev.w3.org/html5/markup/br.html
<br>
element can make use of global attributes, and class
is one of them.