Why does the ‘title’ attribute cause browsers to ignore my styles?

The HTML spec states that there are three kinds of stylesheets: persistent, preferred, and alternate.

  • A stylesheet is “persistent” if it is linked with rel="stylesheet" and has no title attribute. All persistent stylesheets are used when rendering.
  • A stylesheet is “preferred” if it is linked with rel="stylesheet" and has a title attribute; preferred stylesheets with the same title are grouped together, but there should not be more than one group. It seems browsers will choose just one preferred stylesheet to render since there should be only one.
  • Finally, a stylesheet is “alternate” if it is linked with rel="alternate stylesheet" and has a title. These stylesheets are supposed to allow the user to choose stylesheets, they are grouped together by title and show up in the browser’s stylesheet selector if it has one (View >> Page Style in Firefox). Each group (by title) is mutually exclusive.

By putting title attributes on your stylesheets, you’re unwittingly making them into preferred stylesheets rather than the expected persistent stylesheet. This is also why they work when they all have the same title.

Leave a Comment