` is fine.
-
-This might be best practice no. 5: If more specific tags don’t fit,
may suit.
-****
-
-.Keep the Spec on Hand
-****
-[quote,Confucius]
-The beginning of wisdom is to call things by their right names.
-
-The most authoritative resource for learning about HTML is the HTML specification.
-The current specification lives on link:https://html.spec.whatwg.org/multipage[].footnote:[
-The single-page version is too slow to load and render on most computers.
-There's also a developers' edition at /dev, but I prefer the styling of the standard version.]
-There's no need to rely on hearsay to keep up with developments in HTML.
-
-Section 4 features a list of all available elements,
-including what they represent, where they can occur, and what they are allowed to contain.
-It even tells you when you're allowed to leave out closing tags!
-
-Best practice: keep the HTML spec on hand.
-****
-
.Know Your HTML Budget
****
The close relationship between content and markup means that
@@ -289,102 +144,25 @@ Thus, we don't expect every site to contain perfectly conformant HTML.
What's most important is to avoid _wrong_ HTML -- it can be better to fall back on a more generic element than to be precisely incorrect.
If you have the resources, however, putting more care in your HTML will produce a more polished site.
-
-Let’s call that best practice no. 6: A generic loose fit is better than a specific incorrect fit.
****
-// TODO: format as pullout, like Web Components, ARIA
-.The "`Semantic Web`"
-****
-[quote, '_Mean Girls_ (2004)']
-Gretchen, stop trying to make fetch happen! It's not going to happen!
-
-The "Semantic Web" was a vision of a system that could both express any kind of human knowledge, and be useful for computing.
-It planned to achieve this using _ontologies_, repositories of schemas like "person", "movie" and "species" and relations like "named", "part of" and "created by".
-
-The problem with this vision is that information on the Web rarely fits into neat categories.
-Because no single ontology can be defined that encapsulates all kinds of information one might wish to publish on the Web,
-Semantic Web systems need to be pluggable with different schemas.
-In turn, a Semantic Web client, in order to do something useful with an arbitrary piece of HTML, needs to be able to parse these schemas, which means we need to define a standard machine-readable format for ontologies.
-But a single format couldn't express every kind of object and relation...
-It's turtles all the way down.
-
-In practice, most implementations stop at the topmost turtle.
-Ontologies are defined in natural language,
-and clients are hardcoded to support a fixed set of schemas.
-The requirement for prior agreement between server and client means this technology does not have the generality of the Web,
-and for most use cases, you might as well define a JSON API.
-
-_The Semantic Web has nothing to do with semantic HTML_.
-****
-
-
-.Semantic HTML
-****
-[quote,https://t-ravis.com/post/doc/semantic_the_8_letter_s-word/]
-I think being asked to write _meaningful_ HTML better lights the path to realizing that it isn't about what the text means to humans--it's about using tags for the purpose outlined in the specs to meet the needs of software like browsers, assistive technologies, and search engines.
-
-Telling people to "use semantic HTML" instead of "read the spec" has led to a lot of people guessing at the meaning of tags -- "`looks pretty semantic to me!" -- instead of engaging with the spec.
-
-We recommend talking about, and writing, _conformant_ HTML.
-Use the elements to the full extent provided by the HTML specification,
-and let the software take from it whatever meaning they can.
-****
-
-
-[.design-note]
-.Caution: Improvised UI Elements
-****
-Accessibility problems can arise when we try to implement controls that aren't built into HTML.
-
-For example, what if you make something that looks like a set of tabs, but you use radio buttons and CSS hacks to build it?
-
-The problem here is that tabs have requirements beyond clicking to change content.
-Your improvised tabs may be missing features that will lead to user confusion and frustration, as well as some undesirable behaviors.
-From the link:https://www.w3.org/WAI/ARIA/apg/patterns/tabs/[ARIA Authoring Practices Guide on tabs]:
-
-* Keyboard interaction
-
-** Can the tabs be focused with the Tab key?
-
-* ARIA roles, states, and properties
-
-** "`[The element that contains the tabs] has role `tablist`.`"
-
-** "`Each [tab] has role `tab` [...]`"
-
-** "`Each element that contains the content panel for a `tab` has role `tabpanel`.`"
-
-** "`Each [tab] has the property `aria-controls` referring to its associated tabpanel element.`"
-
-** "`The active `tab` element has the state `aria-selected` set to `true` and all other `tab` elements have it set to `false`.`"
-
-** "`Each element with role `tabpanel` has the property `aria-labelledby` referring to its associated `tab` element.`"
-
-You would need to write a lot of code to make your improvised tabs fulfill all of these requirements. Some of the ARIA attributes can be added directly in HTML,
-but they are repetitive
-and others (like `aria-selected`) need to be set through JavaScript since they are dynamic.
-The keyboard interactions can be error-prone too.
-
-It's not impossible to make your own tab set implementation.
-However, it's difficult to trust that a new implementation will work in all environments, since most of us have limited access to testing devices.
-
-Hence, hypermedia best practice no. 7: Stick with established libraries for UI interactions. If a use case requires an improvised solution, test carefully for keyboard interaction and accessibility.
-****
// TODO: check. Does this list accurately condense the work of ch.3?
[.design-note]
-.Best Practices for Effective HTML
+.Toward Effective HTML
****
-1. Stay close to the HTML markup you’re producing and be able to change it.
-2. Make the full tool shed of available tags your own; keep the HTML spec on hand.
-3. Aim for good tag fit, where tag specs match your use case.
-4. If more specific tags don’t fit,
may suit. A generic loose fit is better than a specific incorrect fit.
-5. Stick with established libraries for UI interactions. If a use case requires an improvised solution, test carefully for keyboard interaction and accessibility.
-6. Prefer components that extend HTML, rather than abstracting it away.
-7. Test, and test with screenreaders, with a keyboard, with different browsers and hardware.
+Throughout the book we discuss a number of best practices for writing effective HTML. Here's a nutshell version:
+
+* Stay close to the HTML markup you’re producing and be able to change it. Prefer frameworks and components that help you do this.
+// TODO: maybe add. Aim for 'locality of behavior' in your markup, so that you or another developer can understand what each part of the page is doing just by looking at that part of the page.
+* Make the full range of available tags part of your toolkit.
+* Aim for good fit between tag specs and your use case; check the HTML specs when in doubt.
+* When more specific tags don’t fit, it is okay -- and usually better -- to step back to
than to use a tag incorrectly.
+* Stick with established libraries for UI interactions. If a use case requires an improvised solution, test carefully for keyboard interaction and accessibility.
+* Prefer components that extend HTML, rather than abstracting it away.
+* Test your HTML with screenreaders, with a keyboard, with different browsers and hardware, and run linters (while coding and/or in CI).
****
@@ -409,6 +187,7 @@ Some resources we recommend:
** [.cite]_semantic: the 8 letter s-word_, https://t-ravis.com/post/doc/semantic_the_8_letter_s-word/
****
+
// TODO: format as info gem
.About Display: none
****
@@ -451,7 +230,7 @@ But sometimes it's possible to achieve an equal (or better!) quality of UX while
****
-// TODO: Nice writing here. Some readers may want more specific advice: what does it mean to write HTML for humans?
+// TODO: Some readers may want more specific advice: what does it mean to write HTML for humans?
.Screen Reader Rage
****
The spec is a good starting point when deciding how to mark something up,
@@ -473,61 +252,6 @@ HTML is for humans.
****
-// maybe: discuss data options as part of Data API chapter
-// or, cut if you don't recommend using
-.Microformats
-****
-In some cases you may want to include machine-readable structured data in HTML.
-https://microformats.org/[Microformats] is one standard for doing so.
-It uses classes to mark certain elements as containing information to be extracted.
-The microformats2 standard uses five kinds of classes:
-
-* `h-` classes denote that an element represents a machine-readable entity, e.g., `h-entry`, `h-resume`
-* The other prefixes denote that an element represents properties of an enclosing entity:
-** `p-` classes are plain text properties, from an element's inner text or `alt` attribute, e.g., `p-name`, `p-category`
-** `u-` classes are URL properties, from an element's `href` or `src`, e.g., `u-url`, `u-email`, `u-photo`
-** `dt-` classes are date/time properties, from `
` elements, e.g., `dt-published`, `dt-updated`
-** `e-` classes are embedded markup properties, from an element's inner HTML, e.g., `e-content`, `e-description`
-
-There are also conventions for extracting common properties like name, URL and photo without needing classes for each property.
-
-By adding these classes into the HTML representation of an object, we allow the properties of the object to be recovered from the HTML. For example, this simple HTML:
-
-[source,html]
-----
-
- John Doe
-
-----
-
-can be parsed into this JSON-like structure:
-// maybe: briefly describe how
-
-
-[source,json]
-----
-{
- "type": ["h-card"],
- "properties": {
- "name": ["John Doe"],
- "photo": ["john.jpg"],
- ""
- "url": ["https://john.example"]
- }
-}
-----
-
-Using a variety of properties and nested objects, we could mark up every bit of information about a contact, for example, in a machine-readable way.
-
-// maybe: rule of thumb for when to use a microformat
-// Would this be worthwhile for contact.app?
-Microformats and the extensibility of HTML can prove useful, but embedding data in HTML is not appropriate for every use case.
-Your human-facing and machine-facing interfaces may end up being limited by each other.
-It's often the best option to define a JSON data API separate from your HTML.
-****
-
-
-
// maybe move to ch1, The Essence of HTML as a Hypermedia
.What is HTML?
****
@@ -550,4 +274,30 @@ HTML is a hypermedium.
An HTML file is not a program that produces a human-readable document.
It _is_ the document.
+****
+
+
+// TODO: keep? format as pullout, like Web Components, ARIA
+.The "`Semantic Web`"
+****
+[quote, '_Mean Girls_ (2004)']
+Gretchen, stop trying to make fetch happen! It's not going to happen!
+
+The "Semantic Web" was a vision of a system that could both express any kind of human knowledge, and be useful for computing.
+It planned to achieve this using _ontologies_, repositories of schemas like "person", "movie" and "species" and relations like "named", "part of" and "created by".
+
+The problem with this vision is that information on the Web rarely fits into neat categories.
+Because no single ontology can be defined that encapsulates all kinds of information one might wish to publish on the Web,
+Semantic Web systems need to be pluggable with different schemas.
+In turn, a Semantic Web client, in order to do something useful with an arbitrary piece of HTML, needs to be able to parse these schemas, which means we need to define a standard machine-readable format for ontologies.
+But a single format couldn't express every kind of object and relation...
+It's turtles all the way down.
+
+In practice, most implementations stop at the topmost turtle.
+Ontologies are defined in natural language,
+and clients are hardcoded to support a fixed set of schemas.
+The requirement for prior agreement between server and client means this technology does not have the generality of the Web,
+and for most use cases, you might as well define a JSON API.
+
+_The Semantic Web has nothing to do with semantic HTML_.
****
\ No newline at end of file
diff --git a/book/CH04_BuildingASimpleWebApplication.adoc b/book/CH04_BuildingASimpleWebApplication.adoc
index d2533d2..a1d8c30 100644
--- a/book/CH04_BuildingASimpleWebApplication.adoc
+++ b/book/CH04_BuildingASimpleWebApplication.adoc
@@ -859,3 +859,17 @@ No. No it isn't.
It turns out that we can improve the user experience of this application within the
hypermedia architecture. In the next few chapters we will look at https://htmx.org[htmx], a hypermedia-oriented library
that will let us improve our contact application _without_ abandoning the hypermedia approach we have used so far.
+
+
+[.design-note]
+.HTML Note: Semantic HTML
+****
+[quote,https://t-ravis.com/post/doc/semantic_the_8_letter_s-word/]
+I think being asked to write _meaningful_ HTML better lights the path to realizing that it isn't about what the text means to humans--it's about using tags for the purpose outlined in the specs to meet the needs of software like browsers, assistive technologies, and search engines.
+
+Telling people to "use semantic HTML" instead of "read the spec" has led to a lot of people guessing at the meaning of tags -- "`looks pretty semantic to me!" -- instead of engaging with the spec.
+
+We recommend talking about, and writing, _conformant_ HTML.
+Use the elements to the full extent provided by the HTML specification,
+and let the software take from it whatever meaning they can.
+****
diff --git a/book/CH05_ExtendingHTMLAsHypermedia.adoc b/book/CH05_ExtendingHTMLAsHypermedia.adoc
index dad04f7..adc244c 100644
--- a/book/CH05_ExtendingHTMLAsHypermedia.adoc
+++ b/book/CH05_ExtendingHTMLAsHypermedia.adoc
@@ -891,3 +891,44 @@ By staying closer to the original model of the web, htmx aims to strike a balanc
deferring to other libraries for more elaborate frontend extensions on top of the existing web platform. The good news
is that htmx plays well with others, so when these needs arise it is often easy enough to bring in another library to handle
them.
+
+
+[.design-note]
+.HTML Note: Caution with Improvised UI Elements
+****
+Accessibility problems can arise when we try to implement controls that aren't built into HTML.
+
+For example, what if you make something that looks like a set of tabs, but you use radio buttons and CSS hacks to build it?
+
+The problem here is that tabs have requirements beyond clicking to change content.
+Your improvised tabs may be missing features that will lead to user confusion and frustration, as well as some undesirable behaviors.
+From the link:https://www.w3.org/WAI/ARIA/apg/patterns/tabs/[ARIA Authoring Practices Guide on tabs]:
+
+* Keyboard interaction
+
+** Can the tabs be focused with the Tab key?
+
+* ARIA roles, states, and properties
+
+** "`[The element that contains the tabs] has role `tablist`.`"
+
+** "`Each [tab] has role `tab` [...]`"
+
+** "`Each element that contains the content panel for a `tab` has role `tabpanel`.`"
+
+** "`Each [tab] has the property `aria-controls` referring to its associated tabpanel element.`"
+
+** "`The active `tab` element has the state `aria-selected` set to `true` and all other `tab` elements have it set to `false`.`"
+
+** "`Each element with role `tabpanel` has the property `aria-labelledby` referring to its associated `tab` element.`"
+
+You would need to write a lot of code to make your improvised tabs fulfill all of these requirements. Some of the ARIA attributes can be added directly in HTML,
+but they are repetitive
+and others (like `aria-selected`) need to be set through JavaScript since they are dynamic.
+The keyboard interactions can be error-prone too.
+
+It's not impossible to make your own tab set implementation.
+However, it's difficult to trust that a new implementation will work in all environments, since most of us have limited access to testing devices.
+
+Stick with established libraries for UI interactions. If a use case requires an improvised solution, test carefully for keyboard interaction and accessibility.
+****
\ No newline at end of file
diff --git a/book/CH06_htmxPatterns.adoc b/book/CH06_htmxPatterns.adoc
index fda3ad5..ee3a480 100644
--- a/book/CH06_htmxPatterns.adoc
+++ b/book/CH06_htmxPatterns.adoc
@@ -1032,3 +1032,34 @@ And, again, we are doing all this within the original, RESTful model of the web.
behavior, we are still exchanging hypermedia with the server, with no JSON API response to be seen.
As the web was designed.
+
+
+[.design-note]
+.Component Soup?
+****
+Components encapsulate a section of a page along with its dynamic behavior.
+While encapsulating behavior is a good way to organize code,
+it can also separate elements from their surrounding context,
+which can lead to wrong or inadequate relationships between elements.
+The result is what one might call [.dfn]_component soup_,
+where information is hidden in component state,
+rather than being present in the HTML, which is now incomprehensible due to missing context.
+
+Before you reach for components for reuse, consider your options.
+Lower-level mechanisms often (allow you to) produce better HTML.
+In some cases, components can actually _improve_ the clarity of your HTML.
+
+To decide if a component is appropriate for your use case, a good rule of thumb is to ask:
+"`Could this reasonably be a built-in HTML element?`"
+For example, a code editor is a good candidate,
+since HTML already has `