Using the HTML `
` Tag to Create Line Breaks: Precise Text Formatting
Learn how to use the HTML `
` tag to insert line breaks in your web content. This tutorial explains the difference between `
` and `
`, demonstrates its usage for precise text formatting, and highlights its application in displaying poems, addresses, and other text-based content.
Using the HTML `
` Tag to Create Line Breaks
Understanding Line Breaks in HTML
In HTML, the `
` tag (break) inserts a single line break. This is different from creating a new paragraph (`<p>`) because it doesn't add extra vertical spacing; it simply moves the following content to the next line. This makes it very useful for formatting addresses, poems, or other types of text where preserving line breaks is needed. The `
` tag is an empty tag; it doesn't have a closing tag.
Using the `
` Tag
To add a line break, simply insert the `
` tag where you want the break to occur. For example:
Example: Using `
`
<p>This is a single line of text.<br>
This is a second line.</p>
Note that the `
` tag is an inline element, meaning that it does not add extra space or line breaks before or after the break itself. Multiple line breaks will generally be rendered as a single line break.
Browser Support for `
`
The `
` tag is supported by all major modern browsers.
Browser | Support |
---|---|
Chrome | Yes |
Edge | Yes |
Firefox | Yes |
Opera | Yes |
Safari | Yes |
Using `
` in Poems
The `
` tag is especially useful when displaying poems or other text where you need precise line breaks. Without using `
`, the browser might render the entire poem on a single line, making it hard to read.
Example: `
` in a Poem
<p>
Roses are red,<br>
Violets are blue,<br>
Sugar is sweet,<br>
And so are you.
</p>