HTML Statistics: 5 Take-Aways
Published on February 13, 2017 (↻ November 27, 2023), filed under Development (RSS feed for all categories).
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 frontend engineering leader and tech author/publisher. I’ve worked as a technical lead for companies like Google and as an engineering manager for companies like Miro, I’m a contributor to several web standards, 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. (Please be critical, interpret charitably, and give feedback.)
Read More
Maybe of interest to you, too:
- Next: Principles of Web Development
- Previous: 10 Photos IV
- More under Development
- More from 2017
- Most popular posts
Looking for a way to comment? Comments have been disabled, unfortunately.
Get a good look at web development? Try WebGlossary.info—and The Web Development Glossary 3K. With explanations and definitions for thousands of terms of web development, web design, and related fields, building on Wikipedia as well as MDN Web Docs. Available at Apple Books, Kobo, Google Play Books, and Leanpub.