Avery Hymel

What is Nesting in PDF Accessibility and Why is it Important?

When we refer to the nesting of tags, we are talking about the presence of tags inside other tags. Synonymously, when a tag contains other tags, that “parent” tag is said to contain a “substructure.”

And, when it comes to PDF tagging, there are “containment,” or nesting rules, around what tags are allowed – or even required – to be nested inside other tags.

That said, this may or may not be a concept you must pay much attention to in your day-to-day PDF remediation work, depending on the content of your documents.

For example, if your documents are relatively simple, the only nesting you may have in your tags is the Document tag containing all other tags in the PDF. The Document tag is required to be the first, and only, child of the Tags root. All of the other tags in a document should be nested inside that Document tag.

Of course, you’ll need to be aware of some additional nesting rules in more complex documents with Tables of Contents, footnotes, lists, or tables. However, with some guidance, recognizing proper PDF tag nesting and correctly implementing this nesting can become second nature within your PDF remediation workflow.

What is tag nesting and how does it impact PDF accessibility?

PDF tags are the behind-the-scenes containers that determine, among other things, how a PDF document is read by assistive technology. 

If tags are inaccurate or in an incorrect order, the reading experience could be, at best, confusing and, at worse, completely impossible! 

Sometimes, the order and organization of these tags is up to the remediator to decide. For example, do you want this to be read before or after that? However, other times, the structure of the tags is written according to the PDF accessibility standard, and not following those rules precisely will result in an incompliant document.

When it comes to nesting tags, if you have an image in a list item, for example, you would need to ensure your Figure tag is properly nested inside the List’s substructure. This nesting, then, provides critical context to the reader. The nesting of the Figure tag inside the list’s substructure indicates that the graphic is literally inside, or part of, that list, rather than it falling before the list, after the list, or breaking it.

Another component of nesting is a tag’s placement value. A tag’s placement value determines if a tag can, or even should, have additional tags within it or if it must be nested inside of other “structural” tags. A placement value can be changed in some scenarios, but in broad terms, it’s important to know that this value determines a tag’s nesting requirements.

Why is tag nesting important for PDF accessibility?

Once we understand tag nesting, the intention behind it becomes more relevant. In short, some tags have very specific tag structures that must include nesting to be accessible.

For example, if you have a list in your document, you must ensure it is properly tagged as a List.

List tags are required to have LI, or List Item, tags nested within them. There would need to be one LI tag for each item in the list. If your list is 15 items long, the list tag would require fifteen nested LIs.

Furthermore, these LI tags are required to have substructures that offer even more organization to the tags tree. They come in the form of body (LBody) tags and, in most cases, label (Lbl) tags.

The Lbl and LBody tags tell a critical story to the reader, helping explain how the list is compiled, the order of the items in the list, and the numbering mechanism for that particular list.

Additionally, if we want to dig even deeper, some lists have lists within them! We call these lists “nested lists,” and the tag structure is the same in terms of specificity and structural requirements. Other examples of tags requiring nested tags are Tables and Tables of Contents.

Sometimes, nesting is used as an organizational tool. We call tags used for these purposes ”Grouping” tags, and examples include Document, Part, Sect, and Art tags. As previously mentioned, some of these, such as a Document tag, are required. The Document tag contains the entirety of the Tag tree nested within it. Others, such as an Art tag, could be optional in some cases or only used in specific circumstances.

A great application of an Art tag would be grouping a newspaper article that starts on page one but continues onto page nine together. This way, the reader can navigate through the entire article, regardless of its placement in the physical view of that newspaper.

Of course, Grouping tags, such as the Art tag, have their own containment rules.

The Art tag, for example, is not allowed to contain text directly. So, nested inside the Art tag for the newspaper article, you would find heading tags, paragraph tags, and so on, as appropriate to the content.

As you can see, use cases for Grouping tags can vary, but nesting is a critical component of using them correctly.

How to do nesting in PDFs?

How you nest a tag within another depends on your remediation software’s functionality, specific keystrokes, or commands. Typically, this involves inserting and placing tags within a new tag. 

This process’s ease depends on the software, but knowing what should and shouldn’t be nested is the first step to achieving the desired efficiency and accuracy.

Even with an understanding of nesting, common mistakes still arise. 

Unnecessary nesting is one of the main culprits. Some tagging tools may, for example, nest multiple Sect tags inside each other, and while it may not affect the accessibility of the document or how it is read, it is an easy thing to fix when remediating a file. 

Additionally, tags should never be nested directly inside another tag of the same type. For example, a P tag should never have another P within it. These are easy to recognize as you work through the recommended workflow of CommonLook PDF remediation.

Some scenarios have different nesting requirements based on context. For example, a Caption tag can serve two purposes: as a Figure caption or a Table caption. 

A Figure caption should not be nested inside a Figure tag, as the content of the Caption tag will not be read. However, a Caption tag associated with a Table should be nested within the Table tag to ensure it is read with the appropriate content.

These situations may seem wildly specific, and they are, but with intentional practice and repetition, a remediator will recognize these nesting situations effortlessly as they work through a document. 

Feel free to utilize the online resources in our Knowledge Base as you become more comfortable with tagging practices. This comprehensive database contains articles on the vast majority of tagging and nesting structures, which can be very helpful.