diff options
Diffstat (limited to 'build/html-like-1999/index.html')
-rw-r--r-- | build/html-like-1999/index.html | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/build/html-like-1999/index.html b/build/html-like-1999/index.html new file mode 100644 index 0000000..b24d2fd --- /dev/null +++ b/build/html-like-1999/index.html @@ -0,0 +1,83 @@ +<!doctype html> +<html lang="en" id="top"> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <link rel="icon" href="data:,"> + <title>Write HTML Like It's 1999</title> + <link href="https://bt.ht/atom.xml" type="application/atom+xml" rel="alternate" title="Atom feed for blog posts" /> + <style>*{box-sizing:border-box;}body{font-family:sans-serif;margin:0 auto;max-width:650px;padding:1rem;}img{max-width:100%;}pre{overflow:auto;}table{text-align:left;width:100%;}</style> +</head> + +<nav> + <a href="#menu">Menu ↓</a> +</nav> + +<main> +<h1>Write HTML Like It's 1999</h1> +<p>2019-06-06</p> +<p>I am sure it's safe to say that most developers love to use the latest and greatest web tools available. Helpful resources such as preprocessors, template engines, syntax formatters - you name it - can all make a developer's life easier. Unfortunately, this sometimes comes at a cost: the HTML structure.</p> +<p>This is why I try my best to write HTML as if I'm stuck with the constraints of the 90s (within reason). What does this mean exactly? It means that <code>tables</code> are coded with <code>table</code> elements. Navigations are coded with <code>nav</code> and ordered/unordered list-items. Form inputs are not set with <code>display: none</code> and replaced with custom containers. You know, <em>semantic</em> HTML.</p> +<p>To be clear, I'm not advocating for creating projects that <em>look</em> like they belong in the 1990s. I would just prefer developers / designers be more conscious of their HTML <em>skeleton</em>.</p> +<h2>Bad HTML practices</h2> +<p>Let's do a very simple breakdown of some of the more common HTML no-nos:</p> +<p><ul> +<li>Using <code>span</code> or <code>div</code> elements for navigations or list components</li> +<li>Implementing custom <code>div</code> layouts for forms while removing items like <code>select</code> or <code>radio</code></li> +<li>Creating tables built out of custom <code>div</code> elements</li> +<li>Over-nesting elements or making overly complex depth to simple components</li> +<li>Content being heavily reliant on JavaScript "injection"</li> +</ul></p> +<h2>Good HTML practices</h2> +<p>So what should you do in place of these bad HTML implementations?</p> +<p><ul> +<li>Use proper <code>nav</code>, <code>ul</code> and <code>ol</code> for navigations or list components</li> +<li>Style form elements directly <a href="https://www.filamentgroup.com/lab/select-css.html">this is already supported in browsers</a></li> +<li>Build tables using <code>table</code> element structure (mind-blowing, I know!)</li> +<li>Keep element hierarchy as slim and top level as possible</li> +<li>Avoid injecting <i>any</i> content via JavaScript (I understand this is difficult for certain apps, but try to minimize this as much as possible)</li> +</ul></p> +<h2>My basic "structure" test</h2> +<p>I've found a pretty simple starting point for testing the <em>bones of a website</em> by using the following single line of CSS:</p> +<pre><code>* { + border: 2px dotted black; +} +</code></pre> +<p>This property simply outlines all elements on the current page in a dotted border. By placing a border on every HTML element you can instantly see how overly complex or <em>ugly</em> your structure might be under the hood.</p> +<h2>"Thanks, Captain Obvious!"</h2> +<p>I know, this stuff is pretty basic. The point of this post isn't to tell you (developers) something brand new or mind-blowing, but instead should inspire you to keep things simple.</p> +<p>Don't forget that there is always someone new into the world of design and development. Hopefully this post steers others towards keeping HTML code semantic and clean.</p> +<h2>Update to this article</h2> +<p>Since this post received <a href="https://news.ycombinator.com/item?id=20133817">so much more attention</a> than I ever expected, I've decided to touch on a few small points brought up in the comments.</p> +<ol> +<li><p><strong>What is the benefit of semantic HTML?</strong> + - Accessibility. Programs like screen readers are built around the foundation of proper HTML hierarchy. I highly recommend testing all your projects with a screen reader - it will open your eyes to a lot of issues users with disabilities suffer through.</p> +</li> +<li><p><strong>Tables not being responsive</strong> + - This simply isn't true. It is much more semantic to layout your tables as you would normally, then for mobile devices you can target specific inner elements and alter them with <code>flexbox</code> etc. (You can see responsive tables in action <a href="/responsive-tables">here</a>)</p> +</li> +<li><p><strong>Instead of the CSS one-liner, simply use Firefox debugger</strong> + - Fair point. Firefox is great!</p> +</li> +</ol> +<footer role="contentinfo"> + <h2>Menu Navigation</h2> + <ul id="menu"> + <li><a href="/">Home</a></li> + <li><a href="/projects">Projects</a></li> + <li><a href="/uses">Uses</a></li> + <li><a href="/wiki">Wiki</a></li> + <li><a href="/resume">Resume</a></li> + <li><a href="/colophon">Colophon</a></li> + <li><a href="/now">Now</a></li> + <li><a href="/donate">Donate</a></li> + <li><a href="/atom.xml">RSS</a></li> + <li><a href="#top">↑ Top of the page</a></li> + </ul> + <small> + Built with <a href="https://git.sr.ht/~bt/barf">barf</a>. <br> + Maintained with ♥ for the web. <br> + Proud supporter of <a href="https://usefathom.com/ref/DKHJVX">Fathom</a> & <a href="https://nextdns.io/?from=74d3p3h8">NextDNS</a>. <br> + The content for this site is <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>.<br> The <a href="https://git.sr.ht/~bt/bt.ht">code for this site</a> is <a href="https://git.sr.ht/~bt/bt.ht/tree/master/item/LICENSE">MIT</a>. + </small> +</footer>
\ No newline at end of file |