HTML <br> Tag: Unraveling Its Usage, Attributes, and Real-Life Examples

By Cristian G. Guasch •  Updated: 09/25/23 •  9 min read

When you’re diving into the world of web development, understanding HTML is crucial. It’s the backbone of web design and one element that you’ll undoubtedly encounter is the humble <br> tag. This little piece of code may appear insignificant, but don’t be fooled! The <br> tag plays a pivotal role in creating well-structured and readable content on your webpage.

If I had to describe it in simple terms, the <br> tag is essentially a line-breaker. It’s used to insert a single line break in your text, wherever you need it. Think of it as hitting ‘Enter’ or ‘Return’ while typing up a document – the cursor moves down to the next line, allowing for better organization and readability of your content.

But there’s more to this unassuming tag than meets the eye. In my journey as a blogger and web developer, I’ve discovered several attributes and unique usage scenarios for the <br> tag. By mastering these aspects, you can significantly enhance your website’s layout and user experience.

Understanding HTML Tag Basics

Diving right into the world of HTML, I’ve found it’s a language that forms the building blocks of web development. Although it might seem intimidating at first, understanding its core elements can take you a long way in your journey as a developer.

One essential concept to grasp is the use of tags. Here’s where the <br> tag steps in. It’s simply an instruction to the browser saying “Hey, let’s break this line here and start a new one.” There’s no need for any closing tag – just insert <br> where you want your line break.

I’ve seen lots of beginners mistakenly using multiple <br> tags to create spaces between paragraphs. But I’d advise against it. Why? Because there are other more semantic ways to handle spacing in HTML such as using CSS margin and padding properties or paragraph (<p>) tags.

Let me walk you through an example:

<p>This is my first sentence.<br>This is my second sentence.</p>

In this case, ‘This is my second sentence.’ will appear on a new line directly under ‘This is my first sentence.’ Remember that browsers ignore extra whitespace and line breaks in the HTML source code so using <br> within text content ensures those breaks appear when rendered.

It’s important not to confuse <br> with other similar tags like <hr>, which creates a thematic break or horizontal rule rather than just moving content down onto the next line. So while they may look similar at times, their intentions are different.

Just like mastering any language, understanding HTML requires practice and patience. Take time to experiment with various tags and see how they impact your webpage layout – you’ll be amazed by what you can achieve!

HTML Tag Attributes: An Overview

Diving into the world of HTML, it’s impossible to ignore the importance of attributes. They’re much like the secret sauce that gives your markup flavor and functionality. For beginners out there, let’s start by understanding what they are.

In essence, HTML attributes provide additional information about an element. You’ll find them always specified in the start tag (well, almost always!). And hey, don’t worry if you’re not catching my drift yet. I’m about to illustrate this with a practical example:

<a href="">Visit our site!</a>

In this simple line of code, “href” is an attribute of the anchor tag <a>. The URL “” is its value. So effectively, we’re telling the browser where to navigate when someone clicks on “Visit our site!”.

Now let’s talk variations! HTML attributes can be categorized into two types: Global and Local. Global attributes are those which can be used with all HTML elements while local ones are specific to certain tags only.

For instance, class and id are global attributes that you’ve probably seen often if you’ve dabbled in styling your web pages with CSS:

<div class="myClass" id="myId">Hello World!</div>

On the other hand, a local attribute like href which we just discussed earlier is specifically for <a> tags.

When coding in HTML it’s easy to make mistakes especially when dealing with attributes. A common one I see a lot is forgetting to put quotation marks around attribute values:

<!-- Incorrect -->
<img src=yourimage.jpg>

<!-- Correct -->
<img src="yourimage.jpg">

Remember folks, attention to detail goes a long way in writing clean and error-free code!

So that’s my two cents on HTML tag attributes. Hopefully, you’re feeling a bit more confident about using them now! Remember practice is key, so don’t be afraid to experiment and learn from your mistakes.
Let’s dive right into the practical examples of HTML tag use. It’s no secret that HTML tags are the building blocks of any webpage, so understanding their application is truly key.

To start with a simple one, let’s consider the <p> tag. This tag is used to define paragraphs in your web content. Here’s how it works:

<p>This is a paragraph.</p>
<p>This too!</p>

In this code snippet, we’ve created two separate paragraphs each enclosed within their own <p> tags.

Another common and important HTML tag you’ll encounter often is the <a> tag which stands for ‘anchor’. This particular tag allows us to create hyperlinks on our webpages. See it in action below:

<a href="">Visit</a>

With this piece of code, clicking on “Visit” will take users directly to

Now let’s switch gears and discuss an attribute-laden HTML element – the <img> tag, used for embedding images onto your webpage:

<img src="image.jpg" alt="A description of the image" width="500" height="600">

Here src specifies the path to the image file, alt provides alternative text when the image can’t be displayed, while width and height dictate size dimensions.

But I must caution you! A common mistake folks make is forgetting to close their tags properly or missing out essential attributes such as alt in an image tag which aids accessibility.

Remember these examples as you navigate through your coding journey because practice makes perfect!
Let’s dive right into some of the common mistakes that tend to crop up when working with HTML tags. Now, I’m not here to point fingers or make anyone feel bad about their coding abilities. Instead, my goal is to help fellow coders avoid these pitfalls and improve their HTML skills.

One of the most frequent errors made by beginners revolves around forgetting to close tags. Let’s say you’re writing a paragraph using the <p> tag. It should look something like this:

<p>This is a sample paragraph</p>

But what if you forget that closing </p>? You’ll end up with all subsequent content on your page being treated as part of that single paragraph until another closing </p> tag is found. Not exactly what we want, right?

Another common error involves nesting tags incorrectly. In HTML, it’s important to remember that the last tag opened should be the first one closed. This “last in, first out” approach ensures proper structure and readability of your code. For instance:

<b><i>This text is bold and italicized.</b></i> // Incorrect
<b><i>This text is bold and italicized.</i></b> // Correct

In the incorrect example above, we are attempting to close our <b> (bold) tag before closing our <i> (italicize) tag – creating an improper nest.

We also see issues arise when folks use deprecated or obsolete tags – ones that have been phased out over time due to changes in best practices or technology advances. For instance, many folks still use <font> for changing font colors when they should be utilizing CSS instead.

Lastly, there’s misuse of block-level elements within inline elements – it’s a no-no in HTML world! Block-level elements like paragraphs (<p>) can contain other block-level elements and inline elements but inline elements like span (<span>) should not contain block-level elements. Here’s an example:

<span><p>This is incorrect usage</p></span> // Incorrect
<p><span>This is correct usage</span></p> // Correct

The incorrect code above attempts to nest a paragraph tag within a span tag – something that will lead to unexpected results or errors.

Avoiding these common mistakes can make your HTML cleaner, easier to read, and more effective. Remember, nobody becomes an expert coder overnight so don’t be too hard on yourself if you stumble upon these errors in your own work. Just keep practicing, learning from the mistakes, and moving forward – you’ll get there!

Concluding Thoughts on HTML Tags

I’ve spent a lot of time discussing the importance and functionality of HTML tags, specifically focusing on the <br> tag. I hope this discussion and examples throughout the article have provided you with a clear understanding of how to implement these tags in your own coding projects.

HTML tags are the backbone of any webpage. They provide structure, design, and interactive elements that make our web experiences enjoyable. The <br> tag is just one simple example, but it’s crucial for text formatting. It allows us to insert line breaks into our content without having to resort to complicated CSS or JavaScript solutions.

Here’s an example code snippet:

<p>This is a paragraph.<br>This is after break.</p>

In this case, “This is after break.” will appear on a new line below “This is a paragraph.”

Common mistakes include forgetting to close the <br> tag or using too many consecutively which can lead to excessive spacing in your document layout.


So there you have it. My take on HTML tags, their uses, attributes, and some handy examples for good measure. With a bit of practice and patience, you’ll be crafting well-structured websites before you know it!

Cristian G. Guasch

Hey! I'm Cristian Gonzalez, I created HTML Easy to help you learn HTML easily and fast.

Related articles