MakeW3web

Line Breaks

In HTML, line breaks are used to manually create a new line within a block of text, without starting a new paragraph. The `<br>` element represents a line break and is an empty, self-closing tag that does not require a closing tag. It can be used within a paragraph or other text-containing elements to insert a break in the text flow.

Here's an example of how to use line breaks in HTML:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>HTML Line Breaks Example</title>
</head>
<body>
    <h1>Using Line Breaks</h1>
    
    <p>This is an example of a paragraph with a line break.<br>
    The text continues directly below the previous line, without any additional spacing.</p>
    
    <p>Line breaks can also be used to format addresses:<br>
    John Doe<br>
    123 Main Street<br>
    Cityville, CA 12345</p>
    
    <p>Or to separate lines in a poem:<br>
    Roses are red,<br>
    Violets are blue,<br>
    Sugar is sweet,<br>
    And so are you.</p>
</body>
</html>

In this example, the `<br>` elements are used to create line breaks within paragraphs, addresses, and poems. The text continues directly below the previous line, without any additional spacing or margin that a new paragraph would provide.

Keep in mind that while line breaks can be useful for specific formatting needs, it's generally recommended to use paragraphs and other HTML elements to structure and organize your content. Line breaks should be used sparingly and only when necessary, such as when formatting addresses, poetry, or other content that requires a specific layout without the added spacing of a new paragraph.

Was this page helpful?