<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[JScamelCase]]></title><description><![CDATA[JScamelCase]]></description><link>https://jscamelcase.io</link><generator>RSS for Node</generator><lastBuildDate>Thu, 23 Apr 2026 18:35:36 GMT</lastBuildDate><atom:link href="https://jscamelcase.io/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[5 Bad HTML Habits to Avoid]]></title><description><![CDATA[HTML Does Matter
HTML, short for HyperText Markup Language, is considered the easier part of web development. As a markup rather than a programming language, HTML doesn't require a high degree of logic to master. For an in-depth look at why HTML is e...]]></description><link>https://jscamelcase.io/5-bad-html-habits-to-avoid</link><guid isPermaLink="true">https://jscamelcase.io/5-bad-html-habits-to-avoid</guid><category><![CDATA[HTML5]]></category><category><![CDATA[HTML tags ]]></category><dc:creator><![CDATA[Carl Paraskevas]]></dc:creator><pubDate>Sat, 30 Dec 2023 21:25:03 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1703971298588/f21d1ad7-0552-4f9f-9322-2a5c57578300.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-html-does-matter">HTML Does Matter</h2>
<p>HTML, short for HyperText Markup Language, is considered the easier part of web development. <strong>As a markup rather than a programming language, HTML doesn't require a high degree of logic to master.</strong> For an in-depth look at why HTML is easier than a full blown programming language like JavaScript, I highly recommend reading <a target="_blank" href="https://www.theserverside.com/feature/Is-HTML-a-programming-language">this</a> article by Darcy DeClute. Aside from being easy, <strong>HTML is also pretty forgiving in terms of mistakes</strong>. For example, a forgotten closing tag here or there, or some misspelled syntax, won't necessarily stop a web page from rendering.</p>
<h3 id="heading-html-ignores-a-missing-tag">HTML Ignores a Missing Tag</h3>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://codepen.io/CPEconomist/pen/mdoyXJo">https://codepen.io/CPEconomist/pen/mdoyXJo</a></div>
<p> </p>
<p>Unfortunately, <strong>HTML's easiness and forgiving nature, often makes front-end developers far too lax about their HTML code</strong>. Don't forget, HTML, despite its many shortcomings, is still a foundational pillar of web development. Being reckless with HTML comes with some dire consequences, especially in areas related to SEO and accessibility. Below, I've listed the 5 common bad HTML habits I've come across during code reviews over the years and the corresponding best practices.</p>
<hr />
<h2 id="heading-1-ltdivgt-overuse">#1 &lt;div&gt; Overuse</h2>
<p>The &lt;div&gt; element is the jack of all trades when it comes to CSS. <strong>If one needs a container in order style, then a &lt;div&gt; might be the right choice.</strong> The downside of using a &lt;div&gt;, however, is it doesn't contain any semantic information about the page. In today's modern web environment, where accessibility is of paramount importance, <strong>its best to exhaust all the semantic elements HTML has to offer, before making a grab for a &lt;div&gt;</strong>. Placing text directly between a &lt;div&gt; is definitely an inferior option to wrapping it between a paragraph (&lt;p&gt;) tag. Semantic HTML elements go a long way in helping screen readers and other assisted technologies interpret a site. In particular, many forget to use the structuring semantic element listed below.</p>
<h3 id="heading-semantic-structure-elements">Semantic "Structure" Elements</h3>
<pre><code class="lang-xml"><span class="hljs-comment">&lt;!-- Grab these semantic tags instead of a &lt;div&gt; to 
structure you page: --&gt;</span>

<span class="hljs-comment">&lt;!-- MAIN --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">main</span>&gt;</span> 
Main should contain the main part of the page, 
but not repeated content like header or footer content. A
page should only have one main tag.
<span class="hljs-tag">&lt;/<span class="hljs-name">main</span>&gt;</span>

<span class="hljs-comment">&lt;!-- SECTION --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">section</span>&gt;</span>
Use section to define a generic area of a page.
If someplace on a page has natural heading attached, odds
are it should be inside a section element.
<span class="hljs-tag">&lt;/<span class="hljs-name">section</span>&gt;</span>

<span class="hljs-comment">&lt;!-- NAV --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">nav</span>&gt;</span>
Use to wrap main navigation links. The typical ul
and li navigation pattern should have a nav parent 
someplace
<span class="hljs-tag">&lt;/<span class="hljs-name">nav</span>&gt;</span>

<span class="hljs-comment">&lt;!-- ARTICLE --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">article</span>&gt;</span>
Articles wrap self-cotnained pieces of content. Artilces
may be ancestors of sections and also descendent of a section.
<span class="hljs-tag">&lt;/<span class="hljs-name">article</span>&gt;</span>

<span class="hljs-comment">&lt;!-- ASIDE --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">aside</span>&gt;</span>
The aside element should parent content that relates, 
but not directly to other content. Sidebars, tips, maybe even
to contain a quote. 
<span class="hljs-tag">&lt;/<span class="hljs-name">aside</span>&gt;</span>

<span class="hljs-comment">&lt;!-- HEADER --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">header</span>&gt;</span>
Holds the header or introductory content of a page
or a section of a page (not to be confused with the "head"
element.
<span class="hljs-tag">&lt;/<span class="hljs-name">header</span>&gt;</span>
<span class="hljs-comment">&lt;!--FOOTER --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">footer</span>&gt;</span>
Footer holds closing information for either an entire page
or a section. 
<span class="hljs-tag">&lt;/<span class="hljs-name">footer</span>&gt;</span>
</code></pre>
<hr />
<h2 id="heading-2-no-ltimggt-alt-attribute">#2 No &lt;img&gt; Alt Attribute</h2>
<p><img src="https://upload.wikimedia.org/wikipedia/commons/6/6a/Broken-image-389560.svg" alt class="image--center mx-auto" /></p>
<p>The alt attribute on the image tag is hugely important for three reasons. <strong>First, the alt attribute allows the visually impaired to know what is being displayed.</strong> Second, it provides some idea of what was intended to be displayed if the image has issues rendering. Third, search engines look to alt tags to determine the meaning of the page. Good alt image descriptions might just give a web page that extra SEO boost. What makes for a great alt attribute description? Check out <a target="_blank" href="https://allyant.com/6-common-alt-text-mistakes-and-best-practices/?gad_source=1&amp;gclid=CjwKCAiAnL-sBhBnEiwAJRGigkwb8EEEBm2vRDXMFNsZ-f9CiIGk5WntMxu_NBwhF_UOYQRuzwMZ-RoChUMQAvD_BwE">this</a> article from Sam Graves on the Allyant website for some pretty good guidelines.</p>
<hr />
<h2 id="heading-3-inappropriate-buttons">#3 Inappropriate Buttons</h2>
<p><strong>Buttons should be used for actions that affect the website’s front-end or back-end</strong> Meanwhile, <strong>anchor tags (links) should be used for navigation to somewhere on the same page, within the site, or elsewhere on the internet.</strong> If UI/UX calls for something like a button for navigation, then style an anchor element to appear like a button. Using button and anchor tags incorrectly causes massive confusion for those using screen readers.</p>
<hr />
<h2 id="heading-4-using-ltbrgt-element-to-style">#4 Using &lt;br&gt; Element to Style</h2>
<p>Using &lt;br&gt;, the line break element, for some extra spacing on a web page, may be quick fix, but its not the right approach. <strong>In fact, &lt;br&gt; should be reserved only for a single situation: when breaks are actually part of the content, such as in poems or addresses</strong>. The following taken from WC3 exhibits what's good and bad practice:</p>
<h3 id="heading-ltbrgt-good-amp-bad-practice">&lt;br&gt; Good &amp; Bad Practice</h3>
<pre><code class="lang-xml"><span class="hljs-comment">&lt;!-- Good Practice --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>P. Sherman<span class="hljs-tag">&lt;<span class="hljs-name">br</span>&gt;</span>
42 Wallaby Way<span class="hljs-tag">&lt;<span class="hljs-name">br</span>&gt;</span>
Sydney<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>

<span class="hljs-comment">&lt;!-- Bad Practice --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">label</span>&gt;</span>Name: <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"name"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">br</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">label</span>&gt;</span>Address: <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"address"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
</code></pre>
<p>Bad use of the &lt;br&gt; throws up all sorts of issues. For one, &lt;br&gt; is not semantic, raising the risk that screen readers and other assistive technologies fail to interpret the line break. In certain cases, &lt;br&gt; elements can also wreck havoc with responsiveness on different types of screen sizes. <strong>Rather than hard code line breaks with &lt;br&gt;, developers should make the most of the margin and padding styling options available through modern CSS to avoid issue.</strong></p>
<hr />
<h2 id="heading-5-using-inline-styles">#5 Using Inline Styles</h2>
<p>Out of all the bad habits mention thus far, styling an element via the style attribute ranks as one of the worst. Event today, a lot of courses and text books introduce the style attribute during the early stages of learning because its easy. I find this remarkable, because it causes major debugging problems later on when trying to style the page through CSS using conditional styling in JavaScript. <strong>The core problem with inline styles is their high degree of specificity relative to other CSS selectors.</strong></p>
<h3 id="heading-css-selectors-by-points">CSS Selectors by Points</h3>
<table><tbody><tr><td><p><strong>CSS Selector</strong></p></td><td><p><strong>Specificity Points</strong></p></td></tr><tr><td><p>Universal Selector (*)</p></td><td><p>0</p></td></tr><tr><td><p>Element or pseudo-element</p></td><td><p>1</p></td></tr><tr><td><p>Class, pseudo-class, attribute</p></td><td><p>10</p></td></tr><tr><td><p>ID selector</p></td><td><p>100</p></td></tr><tr><td><p>Inline style attribute</p></td><td><p>1000</p></td></tr><tr><td><p>!important</p></td><td><p>10000</p></td></tr></tbody></table>

<p>In fact, aside from a CSS declaration made using the !important keyword, inline styles trump every other selector in terms of specificity points. In other words, once inline styles are in place they are very difficult to override from a CSS stylesheet. To avoid this problem, <strong>always style using CSS and never use inline styles!</strong></p>
<hr />
<h2 id="heading-dont-take-html-for-granted">Don't Take HTML for Granted</h2>
<p>The list above represents just a few of the most common bad HTML habits that I've come across. HTML, although easy to learn and forgiving when it comes to syntax, shouldn't be rushed. Well structured HTML is the first step toward a well designed website that fully considers SEO, accessibility, and usability!</p>
]]></content:encoded></item></channel></rss>