# Add a Main Landmark When the Theme Has None

> Marks the theme's main content area with role="main" when the page has no main element, so screen reader users can jump straight to the content.

- Type: HTML
- Runs: Site-wide footer
- Category: [Accessibility](https://wpide.com/library/category/accessibility/)
- Tags: landmarks, screen-reader, theme
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/a11y-main-landmark-fallback/

## Code

```html
<script>
(function () {
    if (document.querySelector('main, [role="main"]')) { return; }
    var area = document.querySelector('#primary, #content, .site-content, .content-area, #main, .entry-content');
    if (area) {
        area.setAttribute('role', 'main');
        if (!area.id) { area.id = 'wpide-main'; }
    }
})();
</script>
```

## Notes

Add your theme's content wrapper to the selector list if it uses a different class or id.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Add a Main Landmark When the Theme Has None" in its snippet library and add it in one click; or create a new HTML snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
