- HTML Tutorial
- HTML Introduction
- HTML Editors
- HTML Basic
- HTML Comments
- HTML Elements
- HTML Attributes
- HTML Id & Classes
- HTML Skeletal Tags
- HTML Heading Tags
- HTML Paragraph Tag
- HTML Line Break Tag
- HTML Pre Tag
- HTML Anchor Tag
- HTML Image Tag
- HTML Horizontal Line Tag
- HTML Inline & Block
- HTML Inline
- HTML Block
- HTML LInks
- HTML Images
- HTML Formatting
- HTML Head
- HTML Head
- HTML Title
- HTML Meta Elements
- HTML Favicon
- HTML Style
- HTML List
- HTML Lists
- HTML Unordered List
- HTML Ordered List
- HTML Description List
- HTML Table
- HTML Tables
- HTML Table Headers
- HTML Table Styling
- HTML Table Colgroup
- HTML Form
- HTML Forms
- HTML Form Elements
- HTML Form Attributes
- HTML Input Types
- HTML Input Attributes
- HTML Form Actions
- HTML Semantic
- HTML Semantics
- HTML Graphics & Media
- HTML Canvas
- HTML SVG
- HTML Video & Audio
- HTML Plug-ins
- iFrames in HTML
- HTML Miscellaneous Tags
- HTML Code Tag
- HTML Entities
- HTML Quotation
- HTML Global Attributes
- HTML Obsolete Tags
- HTML Emojis
- HTML Symbols
- HTML Events
- HTML Colors
HTML Line Break Tag
The line break tag (<br>) is one of the most fundamental elements in HTML. Its primary purpose is to force a line break within a block of text, making the following content start immediately on a new line. While it might seem similar to the paragraph tag (<p>), there is a key functional difference: a paragraph tag creates a structural block with vertical margins (white space) above and below it, whereas the <br> tag simply moves the cursor to the next line without adding extra spacing or semantic separation.
Usage:
- The <br> tag is a "void element" or "empty tag." This means it does not have a closing tag because it doesn't wrap around any content. In standard HTML5, it is written as <br>, though you may see <br /> in older XHTML projects.
- It is most effective when used within inline elements or block-level text containers (like paragraphs or list items) where the flow of text needs to be interrupted manually.
- Example: A common real-world use case is displaying a physical mailing address where each part of the address belongs on its own line but remains part of the same contact block.
<p>
123 Developer Lane<br>
Code City, ST 98765<br>
United States
</p>
Styling:
- By default, the <br> tag has no visual properties of its own; it has no height, width, or color. It is simply an instruction to the browser's rendering engine.
- While you can't directly "style" a line break, you can control the spacing of the text around it by applying CSS properties like
line-heightto the parent element (e.g., the<p>or<div>tag). - In advanced scenarios, you can use CSS media queries to hide or show <br> tags (using
display: none;) to change how text wraps on mobile devices versus desktop screens.
Usage Considerations:
- Use the <br> tag only for "significant" line breaks. Examples include poetry, song lyrics, or addresses.
- Avoid using it for layout purposes. For example, if you want more space between a heading and a paragraph, use the CSS
margin-bottomproperty rather than inserting multiple line breaks. - Modern web design relies on "Responsive Design." Using too many manual line breaks can make your text look awkward on small smartphone screens because the text might wrap naturally before your manual break occurs.
<br><br><br> to create vertical space. This makes your code messy and difficult to maintain. If you decide later that the gap is too big, you have to find and delete every tag manually instead of changing one line of CSS.
Example usage in headings:
Sometimes a heading is too long and needs to be broken up for better visual balance on a landing page:
<h1>Building Better Web Apps<br>One Line at a Time</h1>
Accessibility Considerations:
- Screen readers usually treat a <br> tag as a short pause. This is helpful for poetry but can be confusing if the tag is used improperly for layout.
- When you use <br> to create visual gaps, users with visual impairments might hear "blank line" or experience unnatural silence, which disrupts the flow of the information being read to them.
Historical Usage:
- In the early days of the web (before CSS was powerful), developers used <br> for almost all vertical positioning.
- With the advent of XHTML, the "self-closing" syntax
<br />became mandatory. However, in modern HTML5, the trailing slash is optional. Most modern teams prefer the cleaner<br>unless they are working in a specific XML-based environment.
In summary, the <br> tag is a specialized tool. It is excellent for formatting specific types of content like addresses or lyrics, but it should never be used as a substitute for proper CSS layout techniques. Use it when the break is part of the content, not the design.