liveBook · Manning

Semantic markup

As explained in D3.js in Action, Third Edition

Semantic HTML is the practice of using HTML elements according to their intended structural or interactive meaning.

Semantic markup uses HTML elements according to their structural or interactive meaning. It gives screen readers a logical page layout and can improve search engine optimization. section 10.2.3

Apply semantic elements to structure content and express controls:

  • Use one <h1> for the page title, then use <h2>, <h3>, and other headings for subtitles and navigable structure. section 10.2.3
  • Organize layouts with <header>, <nav>, <main>, <article>, <section>, and <footer> instead of relying only on generic <div> elements. section 10.2.3
  • Represent controls with meaningful <button>, <a>, and <form> elements, and group collections with <ul> or <ol> lists. section 10.2.3
  • For visualizations, expose an accessible SVG with role="img", aria-labelledby, <title>, and <desc>, then provide a data table as an alternative. section 10.3

Accessible visualization structure

A cetacean visualization places its title and introduction in <header>, its chart areas in <main> and <section>, and sources in <footer>. Its SVG identifies itself as an image and describes the plotted data; a button switches to a labeled data table.

How D3.js in Action, Third Edition covers it

How deep it goes
Demonstrates element choices and accessible visualization code, but defers broader accessibility topics such as contrast and keyboard focus.
Examples
Uses a cetacean scatterplot, legends, filter buttons, semantic layout, SVG descriptions, and an alternative downloadable data table.
What it assumes
Assumes basic HTML and visualization structure while teaching semantic element selection through a concrete D3 project.
What you can do after
Build accessible visualization interfaces with meaningful HTML, labeled SVG graphics, stateful buttons, and alternative tabular data.
How it connects
Connects semantic HTML with screen readers, accessibility, search engine optimization, SVG, and data tables.

Also explained in

Compare how 4 books explain semantic markup →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of D3.js in Action, Third Edition. The section links point to the parts of the book it draws on.