Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML: What's the correct form of BR?

How is correct to write the br tag in html?

<br /> 

or

<br> 

or anything else? :))

like image 994
Adam Halasz Avatar asked Nov 26 '10 20:11

Adam Halasz


People also ask

What is Br in form in HTML?

<br> tags can occur in any tag that can contain phrasing elements, such as <form> , which can contain flow elements, which include phrasing elements. Follow this answer to receive notifications.

Which is correct Br or </ br?

If you are outputting HTML on a regular website you can use <br> or <br/> , both are valid anytime you are serving HTML5 as text/html. If you are serving HTML5 as XHTML (i.e. content type application/xhtml+xml, with an XML declaration) then you must use a self closing tag like so: <br/> .

How do you give BR in HTML?

To do a line break in HTML, use the <br> tag. Simply place the tag wherever you want to force a line break. Since an HTML line break is an empty element, there's no closing tag.

What can I use instead of BR in HTML?

There are many ways to break the line without using <br> tag. The used properties are listed below: white-space: pre; It is used to make elements acts like <pre> tag. display: block; It sets the display property of elements to block.


2 Answers

It depends on the doctype you're using. In the original versions of HTML (up to HTML4), only <br> is correct. In XHTML (which is based on XML), only <br /> is correct. In HTML5, both are allowed although <br> is preferred.

like image 78
casablanca Avatar answered Sep 28 '22 15:09

casablanca


It does not need an end tag, so

<br> 

is correct for HTML, and

<br /> 

for XHTML.

like image 28
pyvi Avatar answered Sep 28 '22 15:09

pyvi