site/blog/2025-04-13-xhtml-is-good-actually/index.xhtml
wl 20a071b769
note to self: never push while half asleep
Signed-off-by: wl <zayd@disroot.org>
2025-04-13 03:08:43 -04:00

88 lines
5.3 KiB
HTML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, viewport-fit=cover" />
<title>wanderlost - XHTML is good, actually</title>
<link rel="stylesheet" href="/assets/css/main.css" />
<link rel="alternate"
type="application/rss+xml"
title="Atom"
href="/blog/atom.xml" />
<link rel="alternate"
type="application/rss+xml"
title="RSS"
href="/blog/rss.xml" />
</head>
<body>
<div class="navbar">
<h1 class="title"><a href="/">wanderlost</a></h1>
<a href="/blog/">index</a>
<a href="/blog/atom.xml">atom</a>
<a href="/blog/rss.xml">rss</a>
</div>
<div class="main">
<hr />
<div class="post">
<h1 class="post-title">XHTML is good, actually</h1>
<h2 class="post-date">2025-04-13</h2>
<!-- if Zola just generated compliant XHTML on its own that would be great, but looks like this will have to do -->
<p>About a month or two ago, I finally converted everything I run and currently maintain to XHTML 1.1.
I had been considering it for months and finally decided it was the right decision, and came to the
conclusion that XHTML is far better than HTML.</p>
<h1 id="an-open-web-needs-real-standards">An open web needs real standards</h1>
<p>Unlike the SGML-based HTML, documents in XHTML must be valid. Browsers will let you get away with
some mild errors, but it's far less lenient than normal HTML. While this is one of the most common
things people criticize XHTML for, it's a good thing. Had everyone used XHTML and followed its
standards when it first came out, maybe we wouldn't have the browser monopoly we have today, or at
least not to such a severe extent. The web needs well-formed XML documents, not the sloppily thrown
together garbage HTML allows and borderline encourages. At the start, XHTML was designed with the
intention of fixing this, but many people kept clinging onto their shitty documents. Now so many
pages are still so annoying to parse that only a couple companies actually do it. XHTML could've
helped fix this.</p>
<p>XHTML tags must be properly closed, so it will not let you use <code>&lt;br&gt;</code> instead of <code>&lt;br /&gt;</code>. XHTML
will not let you uppercase your elements and attributes, so you can't <code>&lt;IMG SRC=</code>. XHTML will not
let you mess up nesting (even though some browsers will), so you can't (or at least shouldn't) do
the following:</p>
<pre style="background-color:#2b303b;color:#6c7079;" class="language-xhtml "><code class="language-xhtml"><span style="color:#abb2bf;">&lt;</span><span style="color:#eb6772;">p</span><span style="color:#abb2bf;">&gt;
</span><span style="color:#abb2bf;"> Here&#39;s a list of some things
</span><span style="color:#abb2bf;"> &lt;</span><span style="color:#eb6772;">ul</span><span style="color:#abb2bf;">&gt;
</span><span style="color:#abb2bf;"> &lt;</span><span style="color:#eb6772;">li</span><span style="color:#abb2bf;">&gt;Item&lt;/</span><span style="color:#eb6772;">li</span><span style="color:#abb2bf;">&gt;
</span><span style="color:#abb2bf;"> &lt;</span><span style="color:#eb6772;">li</span><span style="color:#abb2bf;">&gt;Item&lt;/</span><span style="color:#eb6772;">li</span><span style="color:#abb2bf;">&gt;
</span><span style="color:#abb2bf;"> &lt;/</span><span style="color:#eb6772;">ul</span><span style="color:#abb2bf;">&gt;
</span><span style="color:#abb2bf;">&lt;/</span><span style="color:#eb6772;">p</span><span style="color:#abb2bf;">&gt;
</span></code></pre>
<p>As much as people like to make fun of this, it's a positive to have well formed documents be
enforced.</p>
<h1 id="your-own-sanity">Your own sanity</h1>
<p>XHTML forcing documents to be well formed isn't only good for maintaining a true standard, it also
helps you, the author. By requiring everything be valid, it strongly discourages poor formatting,
leaving it easier for you to maintain your site and edit in the future. Using XHTML puts you in
better habits for writing sites and it's yet another reason why its strictness is a good thing.</p>
<h1 id="negatives">Negatives</h1>
<p>As XHTML is an older standard (the oldest full release being the second edition of XHTML 1.1
in late 2010), it misses out on some newer features HTML5 and others brought in. It doesn't have
<code>&lt;summary&gt;</code> or <code>&lt;details&gt;</code>, it doesn't have semantic elements like <code>&lt;main&gt;</code> (though I don't
really think this matters as much), and it doesn't have inline SVG. I don't think any of these
are really an absolute necessity, but the <code>&lt;summary&gt;</code>/<code>&lt;details</code>&gt; tags would be pretty nice.</p>
<h1 id="further-reading">Further reading</h1>
<p>This will be expanded if/when I find more relevant articles.</p>
<ul>
<li><a href="https://web.archive.org/web/20250405011146/https://www.nuegia.net/articles/open%20letter%20to%20webmasters.xhtml">https://web.archive.org/web/20250405011146/https://www.nuegia.net/articles/open%20letter%20to%20webmasters.xhtml</a></li>
</ul>
</div>
</div>
</body>
</html>