WebAIM - Web Accessibility In Mind

E-mail List Archives

Re: Accessible P Tag Usage


From: Patrick H. Lauke
Date: Mar 19, 2019 3:16PM

On 19/03/2019 21:00, <EMAIL REMOVED> wrote:
> Reading the current definition of the <DIV> tag in HTML 5.1 2nd edition (which I think is the latest from the W3C) at https://www.w3.org/TR/2017/REC-html51-20171003/grouping-content.html#elementdef-div, it states:
> <quote> The div element has no special meaning at all. It represents its children. </quote>
> Although the HTML definition doesn't explicitly state it, <DIV> for all intents and purposes is a wrapper or container tag that holds other tags. By itself, it has no semantic meaning.
> WCAG, PDF/UA, and other accessibility standards provide more details by stating (in their various ways) that "all content must be tagged with a semantically appropriate tag" in order to be accessible to all technologies. So Duff Johnson's comment earlier today is correct; we can't have loose "text flopping about in a <div>". It has to be in a tag inside the <DIV>, a semantically-appropriate tag such as <P>, <Hx>, etc.

When the markup is serialised though, "floppy" runs of text inside a
<div> are turned into text nodes in the DOM. Consistently so, in all
user agents. And this has been the case for decades when it comes to HTML.

Note that the definition for <div>
https://www.w3.org/TR/html52/grouping-content.html#elementdef-div says
its content model (unless inside a <dl>) is "Flow content". And flow
content https://www.w3.org/TR/html52/dom.html#flow-content contains,
apart from elements such as <a>, <p>, etc., also pure "text".

> All the stakeholders in accessibility -- users, assistive technologies, content creators, software -- must follow the same standards. All of our A T manufacturers are advised to recognize the tags; so when "text is flopping about in a <div>," there's a good chance that one or more of the technologies will not recognize it which can have the same effect as artifacting that content, hiding it from our end users.

Not if they follow the standard HTML serialisation that's been in place
in user agents for aeons. And follow the actual standard, its rules for
serializing markup into a DOM tree, etc.

Other markup languages/structures like PDF/UA may be different/stricter
here. But for HTML, pure text nodes inside <div>s are allowed and
there's a spec-conformant way in which user agents process them and turn
them into a consistent DOM representation.

> I'm OK with <IMG>, <FIGURE>, <TABLE> and other elements in a <P>. Sometimes that's the only way we have to insert those items into our content and that technique doesn't produce a hard-stop barrier to those who use A T.

I'm not aware of any hard-stop barriers that are the result of "floppy"
text inside a <div> without a <p> or similar around it. Are there any?

Patrick H. Lauke

www.splintered.co.uk | https://github.com/patrickhlauke
http://flickr.com/photos/redux/ | http://redux.deviantart.com
twitter: @patrick_h_lauke | skype: patrick_h_lauke