Fixing Theme and Page-Builder Anchor Behavior Issues (Elementor & OceanWP)
WCAG Focus: WCAG 2.4.1 (A), 2.4.3 (A), 2.1.1 (A)
Popular WordPress themes such as OceanWP and page builders like Elementor attach smooth-scrolling JavaScript handlers to in-page hash links (href="#section"). Many of these scripts call event.preventDefault() and scroll the viewport visually without moving keyboard focus to the target element—or hijack skip-to-content links so pressing Enter scrolls the screen while focus stays stuck in the header.
Why This Pattern Violates WCAG
WCAG 2.4.1 Bypass Blocks (Level A) and WCAG 2.4.3 Focus Order (Level A) fail when activating a skip link or table-of-contents anchor only scrolls visually without updating keyboard focus to the destination section.
WCAG 2.1.1 Keyboard (Level A) requires in-page anchor navigation to leave keyboard users positioned at the target landmark or heading so the next Tab press moves into the destination content.
Code Comparison
Inaccessible Smooth-Scroll Script (Moves Viewport, Strands Focus)
document.querySelectorAll('a[href^="#"]').forEach(function (anchor) {
anchor.addEventListener('click', function (e) {
e.preventDefault();
var target = document.querySelector(anchor.getAttribute('href'));
if (target) target.scrollIntoView({ behavior: 'smooth' });
});
});
Compliant Anchor Navigation Preserving Keyboard Focus
document.querySelectorAll('a[href^="#"]').forEach(function (anchor) {
anchor.addEventListener('click', function () {
var id = anchor.getAttribute('href').slice(1);
var target = id ? document.getElementById(id) : null;
if (target) {
if (!target.hasAttribute('tabindex')) {
target.setAttribute('tabindex', '-1');
}
target.focus({ preventScroll: false });
}
});
});
How to Fix It in WordPress
- Verify skip links and in-page table-of-contents anchors move actual keyboard focus (not just scroll position) when activated with Enter.
- Ensure target containers (such as <main id="main">) accept programmatic focus via tabindex="-1" and avoid smooth-scroll scripts that cancel default browser anchor focus.
- Test skip navigation and section anchor links in themes like OceanWP and Elementor using keyboard Tab + Enter.
Finding This Issue Automatically
Theme and page-builder anchor scripts run globally across every WordPress post and page, breaking skip links and in-page jumps silently. The WP ADA Compliance Check plugin detects and automatically corrects broken anchor and skip-target focus behavior caused by themes and plugins such as Elementor and OceanWP.
WCAG References & Supporting Materials
WCAG Success Criteria
- Understanding WCAG 2.4.1 Bypass Blocks (Level A)
- Understanding WCAG 2.4.3 Focus Order (Level A)
- Understanding WCAG 2.1.1 Keyboard (Level A)
Supporting Documentation & Guides
- W3C Technique G1: Adding a skip link to go directly to the main content — Shows how to provide working skip navigation links at the top of pages.
- W3C Technique H4: Creating a logical tab order through links and controls — Maintaining a predictable keyboard focus sequence without disruptive tabindex overrides.
Subscribe
Subscribe to receive daily Web Accessibility - Did you know? articles in your inbox.

