Skip to main content

Day 69 of 100DaysOfSpec, a, em elements

I am reading and taking notes on the HTML specifications for 100 days as part of #The100DayProject. Read the initial intent/backstory. I am a Microsoft employee but all opinions, comments, etc on this site are my own. I do not speak on behalf of my employer, and thus no comments should be taken as representative of Microsoft's official opinion of the spec. Subsections not listed below were read without comment.

Currently reading in 4.5 Text-level semantics, a new section!

UAs = user agents = browsers and other HTML document parsers/renderers

4.5.1 The a element

  • Whoa: the a element is categorized as 4 different types of content: flow, phrasing, interactive, and palpable.
  • The content model is “Transparent, but there must be no interactive content descendant.” It makes sense that an anchor link can’t contain actionable elements, as its default behavior is to trigger a click event. “Transparent” is a little confusing: it means that the elements required/allowed inside an a element are the same ones as allowed in its parent element—specifically, from the category of content that allowed the a tag to be in the parent in the first place.
  • Besides the default ARIA role (link), you can set button, checkbox, menuitem, menuitemcheckbox, menuitemradio, tab or treeitem
  • If an a element doesn’t have an href attribute, it’s no longer considered a hyperlink, but a placeholder for a hyperlink. In this case, all the other attributes need to be removed.
  • Dang, an a element could contain a section element and, obeying the “transparent” content model rules, still conform to the spec.

Available attributes:

  • href
  • target: spec mentions this is the browsing context for “hyperlink navigation and form submission”. Funny, because the general wisdom currently is that “buttons should be buttons”, i.e. don’t use an anchor link for a form submission.
  • download: “Whether to download the resource instead of navigating to it, and its file name if so”
  • rel: relationship between the document and linked resource
  • hreflang: language of the link resource
  • type: Hint for the type of the referenced resource. Intentionally en-vagueing with “hint for”. I believe I remember in a different section there being complicated instructions for parsing link type and this attribute being non-binding in some way…

4.5.2 The em element

“The em element represents stress emphasis of its contents.”

  • Having nested em elements increase “level of stress”.
  • Stress is not stylistic, it changes semantic meaning of a sentence.

Some splitting-hairs stuff:

The em element isn't a generic "italics" element. Sometimes, text is intended to stand out from the rest of the paragraph, as if it was in a different mood or voice. For this, the i element is more appropriate.

The em element also isn't intended to convey importance; for that purpose, the strong element is more appropriate.

See, this is a bit weird to me. Semantically changing the stress on a sentence more often does imply a different mood or voice. Stress can also convey importance. I think this is a judgement call situation.


My blog uses Webmentions. Responses from sites which likewise support Webmentions, such as Twitter or people’s personal sites, will show up here.

No Webmentions have been sent to this post yet.