Computer >> Computer tutorials >  >> Programming >> HTML

What is the correct way of using <br>, <br/>, or <br /> in HTML?


In HTML, the <br> tag is used for line break. It is an empty tag i.e. no need to add an end tag. Writing <br> tag is perfectly fine.

Let’s see the usage of other br tags i.e. <br/> or <br />,

In HTML, use <br> tag.

In XHTML, the valid way is to use <br/> or <br></br> as mentioned in the XHTML guidelines.

According to w3 guidelines, a space should be included before the trailing / and > of empty elements, for example, <br />. These guidelines are for XHTML documents to render on existing HTML user agents.

What is the correct way of using <br>, <br/>, or <br /> in HTML?

You can try to run the following code to learn the perfect usage of <br> tag

Example

<!DOCTYPE html>
<html>
   <head>
      <title>HTML br Tag</title>
   </head>
   <body>
      <p>This is before the line break<br>
         and this after the line break.
      </p>
   </body>
</html>