aboutsummaryrefslogtreecommitdiff
path: root/build/html-dark-mode
diff options
context:
space:
mode:
authorBradley Taunt <bt@btxx.org>2024-06-06 08:05:12 -0400
committerBradley Taunt <bt@btxx.org>2024-06-06 08:05:12 -0400
commit6b742c459266b18e2b375b35205ce8a6c02f0452 (patch)
treeb16fbb9a045e33dd6c97eb5ab72e6ff4d9237ea3 /build/html-dark-mode
Initial commit
Diffstat (limited to 'build/html-dark-mode')
-rw-r--r--build/html-dark-mode/index.html57
1 files changed, 57 insertions, 0 deletions
diff --git a/build/html-dark-mode/index.html b/build/html-dark-mode/index.html
new file mode 100644
index 0000000..5ea7a85
--- /dev/null
+++ b/build/html-dark-mode/index.html
@@ -0,0 +1,57 @@
+<!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>HTML Dark Mode</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 &darr;</a>
+</nav>
+
+<main>
+<h1>HTML Dark Mode</h1>
+<p>2023-04-11</p>
+<p>I wrote an article back in 2021 called <a href="https://bt.ht/lazy-dev-dark-mode/">The Lazy Developer's Dark
+Mode</a> where I explained how to implement
+a very basic "dark mode" by using the <code>prefers-color-scheme</code> CSS attribute.
+This stills works perfectly fine, and in fact there is a cleaner variation of
+this created by <em>jacksonchen666</em>: <a href="https://jacksonchen666.com/posts/2023-04-09/13-47-16/">These 3 Lines of CSS Will Give You Dark Mode for Free</a>.</p>
+<p>But today I wanted to show how to add dark mode functionality to a website
+without <em>any CSS at all</em>.</p>
+<pre><code>&lt;meta name=&quot;color-scheme&quot; content=&quot;dark light&quot;&gt;
+</code></pre>
+<p>Add that line inside the <code>head</code> tags on your HTML files and you're good to go.</p>
+<h2>Minor Caveat</h2>
+<p>I mentioned this same issue on the official <a href="https://barf.bt.ht/dark-mode/">barf blog
+post</a> but it doesn't hurt to repeat it here.
+Safari still has minor ahref / link color issue when defaulting to browser dark
+mode. If supporting that browser is a deal-breaker for you, I suggest looking
+at my <a href="https://bt.ht/safari-default-dark-mode/">hacky solution</a>.</p>
+<p>Hopefully this helps others to add dark mode to their existing websites and
+projects with minimal effort!</p>
+<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">&uarr; 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> &amp; <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