How is correct to write the br
tag in html
?
<br />
or
<br>
or anything else? :))
<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.
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/> .
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.
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.
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.
It does not need an end tag, so
<br>
is correct for HTML, and
<br />
for XHTML.
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