Skip to main content
Brand and assets
BuildMonitor and contribute
/
Brand and assets
  • Foundations
    • The brand
    • Logo
    • Colors
    • Typography
    • Styles
    • Shadows & radii
    • Spacing & grid
    • Gradients
    • Styling & the sx prop
    • Color tokens
    • More
    • Accessibility
      • Accessible names
      • Headings
      • Images
      • Accessible colors
      • Anchors
      • HTML semantics
      • DOM order
      • Accessible alternatives
      • Debug with the accessibility tree
      • Engineer setup
  • Assets
  • AI references
  • Foundations
  • Accessibility
  • DOM order

The Importance of DOM Order

Maintaining a logical Document Object Model (DOM) order is crucial for ensuring accessibility. This structure is vital because assistive technologies like screen readers interpret and narrate content based on the DOM order, not the visual presentation. Disordering elements in the DOM can lead to a confusing or inaccessible experience for users relying on these technologies.

Why DOM Order is Critical​

Screen Reader Navigation: Users with visual impairments often navigate content using screen readers that read out the elements in the order they appear in the DOM. A logical flow helps these users understand the content structure and context without seeing it. Screen readers also have additional features like browsing the page by title, by list, by links, etc, so they can also miss the information in this configuration too. Keyboard Navigation: Users who rely on keyboards for navigation benefit from a predictable order of focusable elements. This logical sequence allows them to anticipate the flow of interaction, which is crucial for a seamless user experience. SEO: Search engines parse the DOM to understand content hierarchy and relevance. An illogical order can affect how search engines perceive and rank your content.

Example​

A great simple example is the Alan advice section, in the administrator dashboard home page.

By following the design order, we could expect that result (simplified for the example):

<Card>
<Image src="xxx" />
<Tag>Bon à savoir</Tag>
<Title size="md" level="h3">
Restez à jour...
</Title>
<Paragraph>Retrouvez tous nos articles...</Paragraph>
</Card>

In this structure, a screen reader would announce the tags before the title, which might confuse users about the content's hierarchy and focus.

Adjusting Visual Order with Flexbox​

To align the visual order with accessibility best practices while keeping the design intact, you can use CSS Flexbox to visually reorder elements without changing the DOM structure.

<Card>
<Image src="xxx" />
<VStack sx={{ flexDirection: "column-reverse" }}>
<Title size="md" level="h3">
Restez à jour...
</Title>
<Tag>Bon à savoir</Tag>
</VStack>
<Paragraph>Retrouvez tous nos articles...</Paragraph>
</Card>

By wrapping the Title and the Tag in a VStack and reverse the order we change the visual presentation so that the title appears first, aligning with how a screen reader would logically interpret the page based on the DOM order.

Edit this page
Previous
HTML semantics
Next
Accessible alternatives
  • Why DOM Order is Critical
  • Example
  • Adjusting Visual Order with Flexbox