Is the following valid HTML?
<br class="something">
As an HTML element I can't see why it wouldn't be, but I don't think I've ever seen it in use.
Yes, you can add a class attribute to a <br> element.
Yes you can add a class to break tag just like any other element. No you can't add a class dynamically with css as you would need js for that (if that's what you meant). yes you can target a break tag that resides in an element assuming its the only break tag.
Styling with CSS The <br> element has a single, well-defined purpose — to create a line break in a block of text.
But I’ve successfully added the class of hide into an html element so it must work but the question is can you target a specific br tag when it’s the child of an h4 and then have css insert a class? Yes you can add a class to break tag just like any other element.
The <br> tag inserts a single carriage return or breaks in the document. This element has no end tag. Example: In this example, we use <br> tag in p tag to line break the content. Let us consider an example. Type the following HTML code does not use the <BR> tag in notepad, save the document as an HTML file, and open it in a browser.
The <br> tag inserts a single line break. The <br> tag is useful for writing addresses or poems. The <br> tag is an empty tag which means that it has no end tag.
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.
See the specification.
The class
attribute applies to "HTML Elements" (which includes br
elements).
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" }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With