- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the correct way of using
,
, or
in HTML?
There are multiple correct ways to use a br tag in the web documents.
In HTML, a line break is made with the <br> tag. We don't need to close <br> because it's an empty tag. To break a line, either <br/> or <br></br> are acceptable.
However, <br /> tags are used in other web documents like XHTML. But the <br /> tag must possess a space before the trailing /> as it helps XHTML to render the existing HTML user agents.
Syntax
Text <br> text
Following are the examples….
Example: (using <br>)
In the following example we are using <br> tag to allow break in the lines.
<!DOCTYPE html> <html> <body> <p>If you want to break a line <br> in a paragraph, <br> use the BR element in <br> your HTML document.</p> </body> </html>
On executing the above script, the text which is after the tag <br> will get automatically terminated and added to the next line.
Example: (using <br/>)
In the following example we are using <br/> tag to allow break in our lines.
<!DOCTYPE html> <html> <body> <p>If you want to break a line <br/> in a paragraph, <br/> use the BR element in <br/> your HTML document.</p> </body> </html>
When the script gets executed, the text that is after the tag <br/> is terminated and added to the next line.
Advertisements