Hacker News new | ask | show | jobs
by majewsky 3021 days ago
> Often there’s an argument to use tags to create a default set of styles. For most sites, it’s usually a good idea. However, if you’re just overriding those styles pretty much everywhere, I’d say don’t bother. Put them in generic utility classes (e.g. .paragraph, .heading-1, etc) and use them as you need.

Please don't. Tags have semantics for important reasons. Even if you're removing one of those by overriding the default styles, the semantics of tags are still used e.g. for screenreaders. It's not a mistake that HTML 5 added a ton of new semantic tags like <article>, <header>, <footer>, <aside> and <nav>.

1 comments

I think the argument is against adding rules to tags to create a default set of styles, not against using semantic tags throughout the page.

If my understanding is correct, the argument is to use

  <style>
    .my-article {
      background-color: fuchsia;
    }
  </style>
  <article class="my-article">...</article>
rather than

  <style>
    article {
      background-color: fuchsia;
    }
  </style>
  <article>...</article>