<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Gary Miller</title>
    <description>The latest articles on DEV Community by Gary Miller (@gary_miller_b66f5b3322bf7).</description>
    <link>https://dev.to/gary_miller_b66f5b3322bf7</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3634488%2F0d855e9f-72ff-4a79-9e9c-1d25c2df9288.jpg</url>
      <title>DEV Community: Gary Miller</title>
      <link>https://dev.to/gary_miller_b66f5b3322bf7</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/gary_miller_b66f5b3322bf7"/>
    <language>en</language>
    <item>
      <title>The Difference Between &lt;br&gt; and &lt;br/&gt;</title>
      <dc:creator>Gary Miller</dc:creator>
      <pubDate>Fri, 28 Nov 2025 11:01:11 +0000</pubDate>
      <link>https://dev.to/gary_miller_b66f5b3322bf7/the-difference-between-and-3if0</link>
      <guid>https://dev.to/gary_miller_b66f5b3322bf7/the-difference-between-and-3if0</guid>
      <description>&lt;p&gt;
Recently, I was building a small HTML page and stumbled upon something simple: I needed a line break. 
I knew that the &lt;code&gt;&amp;lt;br&amp;gt;&lt;/code&gt; tag does that, but then I noticed that many people write 
&lt;code&gt;&amp;lt;br/&amp;gt;&lt;/code&gt; instead. The slash at the end confused me, so I decided to figure out what the difference is.
&lt;/p&gt;

&lt;p&gt;
At first, I thought one of these options might be outdated or that browsers treat them differently. 
But the more I researched, the more confused I became. Eventually, I sorted it all out - here is what I learned.
&lt;/p&gt;

&lt;h2&gt;No actual difference in how they work&lt;/h2&gt;

&lt;p&gt;
When you write:
&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Hello&amp;lt;br&amp;gt;
world!
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;
and when you write:
&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Hello&amp;lt;br/&amp;gt;
world!
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;
The page looks exactly the same. Browsers treat both versions as the same line break.
&lt;/p&gt;

&lt;p&gt;
This surprised me because I expected some kind of difference. But the real story is more about standards than rendering.
&lt;/p&gt;

&lt;h2&gt;So why are there two versions?&lt;/h2&gt;

&lt;p&gt;
After reading several articles, I found out that it all depends on the &lt;strong&gt;standard&lt;/strong&gt; you are using.
&lt;/p&gt;

&lt;h3&gt;In normal HTML (which everyone uses today)&lt;/h3&gt;

&lt;p&gt;
The correct version is simply:
&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;br&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;
The &lt;code&gt;&amp;lt;br&amp;gt;&lt;/code&gt; tag is a &lt;em&gt;void element&lt;/em&gt; - an element that cannot have any content. 
Because of that, there is nothing to close, so the slash is unnecessary.
&lt;/p&gt;

&lt;h3&gt;In XHTML - you need &amp;lt;br/&amp;gt;&lt;/h3&gt;

&lt;p&gt;
There used to be a stricter variant of HTML called XHTML, which followed XML rules. 
XML requires either a closing tag or a self-closing form:
&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;br/&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;
That's why &lt;code&gt;&amp;lt;br/&amp;gt;&lt;/code&gt; existed: it was required in XHTML. 
And that habit simply carried over into modern HTML, even though browsers no longer need it.
&lt;/p&gt;

&lt;h2&gt;Browsers don’t care - but the standard does&lt;/h2&gt;

&lt;p&gt;
Modern HTML5 officially uses only &lt;code&gt;&amp;lt;br&amp;gt;&lt;/code&gt;. 
The version with a slash is tolerated purely for backward compatibility, but it has no special meaning.
&lt;/p&gt;

&lt;h2&gt;What should you use today?&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;
&lt;strong&gt;If you're writing HTML5&lt;/strong&gt; - use &lt;code&gt;&amp;lt;br&amp;gt;&lt;/code&gt;
&lt;/li&gt;
  &lt;li&gt;
&lt;strong&gt;If you're working with old XHTML markup&lt;/strong&gt; - use &lt;code&gt;&amp;lt;br/&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Since XHTML is mostly gone today, the version without the slash is the standard choice.
&lt;/p&gt;

&lt;h2&gt;My personal takeaway&lt;/h2&gt;

&lt;p&gt;
It’s funny, but I spent almost an hour trying to understand a simple line break tag. 
On the surface there’s no difference, but it feels good to finally understand what’s happening “under the hood.”
&lt;/p&gt;

&lt;p&gt;
Now, whenever I see &lt;code&gt;&amp;lt;br/&amp;gt;&lt;/code&gt;, I know it’s just a leftover from older standards, not some special HTML trick.
&lt;/p&gt;

&lt;p&gt;
If you want, I can also break down other HTML tags in the same simple, beginner-friendly style.
&lt;/p&gt;

</description>
      <category>frontend</category>
      <category>html</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
