Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it out of date to use <br /> tag nowadays? If so, what should I use instead? [closed]

Tags:

html

css

Is it out of date to use
tag nowadays? If so, what should I use instead?
For new line, I coding like this. This is not supposed to do these days?

<br />
<br />
<br />
<br />
like image 232
Foo Avatar asked Jan 07 '13 14:01

Foo


People also ask

What can I use instead of a BR tag?

Instead of using the <br> tag, you should use a semantic HTML element and the CSS margin or padding properties if necessary.

Should I still use br?

HTML 5 only requires <br> however <br/> is still fine. If you were using something like XHTML you would want that to be <br /> anyway..

Do BR tags need to be closed?

The br tag inserts a line break (not a paragraph break). This tag has no content, so it is self closing.

Should I use BR tag in HTML?

The <br> HTML element produces a line break in text (carriage-return). It is useful for writing a poem or an address, where the division of lines is significant.


1 Answers

<br /> is meant to be used as to represent a break in said content, a common example would be an address:

<p>
    20 street name<br />
    City Name<br />
    etc.
</p>

As you can see in the above example, the address is all one group of content, the breaks are only for presentational purposes.

In short: <p> tags should be used to seperate content into blocks, and the <br /> tag should be used for any breaks needed in that content (for presentational purposes, as in the example above)

The <br /> tag is perfectly valid, it's in the current HTML5 spec too.

like image 87
Sean Avatar answered Nov 01 '22 13:11

Sean