Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apply a class to a br tag?

Tags:

html

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.

like image 213
Evanss Avatar asked Jun 05 '13 15:06

Evanss


People also ask

Can you add class to br tag?

Yes, you can add a class attribute to a <br> element.

Can you put a class on a break?

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.

What is the CSS for BR tag?

Styling with CSS The <br> element has a single, well-defined purpose — to create a line break in a block of text.

Can you add a class to break a br tag?

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.

How to use <br> tag in HTML?

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.

Which tag inserts a single line break in HTML?

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.

Is <BR> Class valid in XHTML?

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>.


2 Answers

Yes.

See the specification.

The class attribute applies to "HTML Elements" (which includes br elements).

like image 78
Quentin Avatar answered Oct 07 '22 19:10

Quentin


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"  }
like image 34
Artur Udod Avatar answered Oct 07 '22 20:10

Artur Udod