Minimal dark mode styles for Hacker News antonz.org · 23 points · 9 comments · H...

@best

Minimal dark mode styles for Hacker News antonz.org · 23 points · 9 comments · HN thread

TL;DR The author shares a minimal CSS snippet that gives Hacker News a dark theme by inverting the page with a CSS filter, since HN itself has no dark mode. A second snippet zooms the page on wide screens to offset the small fixed layout. The post argues custom CSS is a better workaround than web frontends or server-side proxies, which are slow, break authentication, or risk rate-limiting.

  • HN has no official dark mode; the usual workaround is custom CSS applied through extensions like Stylus or Userscripts.
  • Custom HN frontends are often slow and break authentication; server-side proxies can get rate-limited or banned.
  • The snippet uses filter: invert(1) hue-rotate(180deg) inside a prefers-color-scheme: dark media query, with a #fff background that the filter turns black.
  • The approach works on any site but degrades on complex styling and also inverts images; HN's simple styles keep results acceptable.
  • An optional media query applies zoom: 1.25 (or 1.5) on screens at least 992px wide to compensate for the tiny fixed-width font.

Discussion The thread is short and mostly practical. Commenters share alternatives and tweaks: a bookmarklet that toggles the inversion on any site, a note that Edge and Chrome have a built-in auto dark mode flag, and a report that Safari will get a similar feature in version 26.3. Several people grumble that HN's maintainers have not added a dark mode, while others point out the OS or browser already offers a light/dark toggle. The mood is mildly annoyed at HN but pragmatic about the workarounds.

  • HN should add a native dark mode (many): Several commenters ask @dang to add a light/dark toggle to the footer. They argue it is a trivial change, with one saying it takes only a few lines of CSS and suggesting the site's developers do not care much about the interface.
  • Browser or OS dark mode already covers it (some): One commenter says the OS or browser already provides a light/dark toggle, so no site-level control is needed. This suggests the snippet itself is enough for most users.
  • Use a browser flag or userscript instead (some): Commenters point to Chrome and Edge's auto dark mode flag and Safari's upcoming equivalent, which apply dark styling to any site and leave photos alone. Others recommend third-party HN sites like oj-hn.com.
  • Bookmarklet works but has tradeoffs (a few): A shared bookmarklet toggles inversion on any page with one click and also re-inverts images, but one commenter reports it slows page rendering on some browsers.
  • Snippet works with Firefox and Dark Reader (a few): One user reports the zoom snippet works well alongside Dark Reader in Firefox, showing the CSS can be combined with existing extensions.

#HackerNews #darkMode #CSS #browserExtensions #webDesign