Skip to content

Paper Cuts in the Web Platform

As with any large system built by a many contributors over many years, the Web Platform has many small mistakes, inconsistencies, irritating behaviors, and missing features. In smaller scale systems these bits of technical debt accumulate over time and some are occasionally even fixed.

Unfortunately due to the requirement of backwards compatibility, many of the things that bother me about building on the web can never be fixed or changed.

This post is a place for me to vent list the changes I might make if I could.

They're loosely categorized, in no particular order, and entirely lacking context. Maybe someday I'll link each of them to their own explanation post (no promises). There's a very good chance that you will disagree with some or all of these changes, so by all means write your own list or write a response explaining why the way things are Is Good Actually™.

HTML

  • <a> should be <link>

  • All elements should be able to be self-closing, and all self-closing elements should include a /

  • <img> elements should have a controls attribute

  • <style> elements should have a src attribute

  • <table> elements should have a src attribute

  • aria-labelfor should exist, and field elements (<input>, <select>, <textarea>) should have a label attribute.

  • href and src attributes should be renamed to url

  • <source> elements should fall back when the linked source produces an error

  • <input> should not exist and we should instead have dedicated elements for each of the input types

  • <option> should support rich content

  • Classes and other space-separated lists should use any unicode whitespace character as a separator

  • <iframe> should be able to have height: auto to expand vertically

  • <textarea> should be able to have height: auto to expand vertically

  • <area>'s coords attribute should use explicit units, and the unitless coordinates should be relative to the image's native coordinate space so that image maps can be responsive

  • <summary> should just be <button>, or <label>

  • <legend> should just be <label>

  • <figcaption> should just be <label>

  • <section> should be able to receive an accessible name from <label>

  • <h1> - <h6> should be <h> with an optional level attribute

  • <head> and <body> are entirely unnecessary. Just put everything directly in <html>

  • <samp> and <var> are unnecessary

  • <time> should automatically format time strings and allow visitors to see the time in their local timezone

CSS

  • @layer should override non-layered styles, or non-layered styles should be part of a default layer with a reserved name that can be ordered among the layers

  • <fieldset> should have normal styles, and not the weird overlapping border behavior

  • :link should match :any-link

JS

  • Date sucks and should go away (Someday we'll be able to use Temporal)

  • Blocks should have been able to be evaluated as expressions

  • throw should be an expression

  • for, while, and do loops should have an else condition

  • loop should exist for infinite loops

  • switch should break implicitly, and use continue to trigger fall-through in the rare case where it's desirable

  • ClassList, Storage, and other Set-like APIs should all use a common interface

  • The standard library should be versioned and imported

  • Field Validation API sucks

    • invalid event is inconsistent
    • submit event is inconsistent
    • validation event is missing
    • :invalid applies before fields are dirty
    • :user-invalid lacks an API to force a field to be dirty
    • field dirty state isn't exposed
    • setCustomValidity only accepts strings
    • native validation messages use popovers which conflict with autocomplete
    • native validation messages don't include a declarative API that can be used to override/translate the messages
  • DocumentFragment nodes should be mountable, or we should have a VirtualFragment node of some sort

  • DOM nodes should have a smaller API surface area by preferring composition over inheritance

  • All DOM events should bubble

  • Events should default to bubble phase instead of capture

  • All Observers should follow the same common interface

  • DOM API needs declarative way to build HTML without rebuilding existing HTML

  • History API Sucks (Someday we'll be able to use the Navigation API)

    • popstate event is inconsistent and should have been some sort of statechange event that is always triggered when transitioning
    • Get rid of the unused second parameter on pushState and replaceState
  • null should exist; undefined should not.

  • The % operator should only return positive values

  • geolocation.getCurrentPosition should return a Promise

  • Field elements need an undo/redo API

  • List-like objects (DOMRectList, NodeList, FileList, etc) should be readonly arrays

  • DOM nodes should be constructable via constructors instead of document.create* methods

  • Intl.DateTimeFormat.prototype.formatToParts should return an object instead of an array

  • Generators should have a way to access the value passed into next the first time next is called

SVG

  • <circle> and <ellipse> should use x and y instead of cx and cy

  • Strokes should have some sort of stroke-align style to be able to shift the stroke to the left or right of the guideline