Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap page body content with <main> element to improve navigating by landmarks #75

Open
mrwweb opened this issue Nov 9, 2022 · 0 comments

Comments

@mrwweb
Copy link

mrwweb commented Nov 9, 2022

Problem: Divi doesn't seem to output a <main> element nor give the option to add one. This means there is a header and footer landmark on the page but not one for the main content for screen reader users that navigate by landmark.

On a recent accessibility audit and remediation project for a Divi site, we were able to resolve this with the following code:

add_action( 'et_before_main_content', __NAMESPACE__ . '\main_open', 0 );
function main_open() {
    echo '<main>';
}

add_action( 'et_after_main_content', __NAMESPACE__ . '\main_close' );
function main_close() {
    echo '</main>';
}

I'm fairly sure that will give a pretty universal fix to most sites using Divi, but I'm not actually a very experienced user, so I'd need others to test and confirm this fix.

Here was the result on our site:

screenshot of Firefox Dev Tools showing highlighted header, main, and footer elements in the page markup. The main element is a direct descendant and first child of the div with the ID "et-main-area". It is immediately followed by the footer element with ID "main-footer"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant