HTML Statistics: 5 Take-Aways
Published on FebĀ 13, 2017 (updated NovĀ 27, 2023), filed under development, html (feed). (Share this on Mastodon orĀ Bluesky?)
A few quick comments on Catalin Rosuās interesting follow-up analysis of his sampling of eight million websites. Some practices, those that can be considered commendable, are wonderful to note, others Catalin and Chris have already justly commented on, yet one or the other point drowned. I find this a great opportunity to review.
Hiding DOM elements: Instead of using presentational class names we should, as always, use functional or generic names.
no-js
HTML class:no-js
is an anti-pattern because on the one hand, the class reflects dynamic state (behavior) in a permanent fashion (structure), and on the other, links a general problem (scripting fallbacks) to a specific solution (JavaScript), and so we should avoid it (or use a different nameāat Google, some teams had decided for āgoogleā, a name that can be justified on the root element while affording the needed hook).lang
: There are problems withlang
, from the possibility to set language on a server level to making the issue of language detection a software problem, and in many cases we donāt need it..clearfix
vs..clear
vs..cf
: Naming best practices donāt yield to popularity. We should clear containers with what we have in the markup, and if there are no hooks, then we should use functional or generic names again. As for clearfixes in general, letās just useoverflow
.Void elements: A bit snarky, are the people who suggest not to close void elements āfor brevityā the ones who are still afraid of omitting optional tags? The recommendation is spot on, and thereās good reason to go as far as to omit everything thatās optional, for the same brevityāespecially when brevity not only aids performance but also understanding.
ā§ One or the other point may seem strict but what they all reflect is the idea of tailoring, of only using whatās necessary and avoiding everything thatās unnecessary and, of course,āthe idea of quality.
About Me
Iām Jens (long: Jens Oliver Meiert), and Iām a web developer, manager, and author. Iāve been working as a technical lead and engineering manager for companies youāve never heard of and companies you use every day, Iām an occasional contributor to web standards (like HTML, CSS, WCAG), and I write and review books for OāReilly and Frontend Dogma.
I love trying things, not only in web development and engineering management, but also in other areas like philosophy. Here on meiert.com I share some of my experiences and views. (I value you being critical, interpreting charitably, and giving feedback.)