Accessibility CSS Beginner

Underline Links in Post Content

Underline links inside posts and pages, so they can be spotted without relying on colour alone.

Tested on WordPress 7.1 No plugin needed Updated
style.css 11 lines
.entry-content a:not(.wp-element-button):not(.wp-block-button__link),
.wp-block-post-content a:not(.wp-element-button):not(.wp-block-button__link) {
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.18em;
}

.entry-content a:not(.wp-element-button):not(.wp-block-button__link):hover,
.wp-block-post-content a:not(.wp-element-button):not(.wp-block-button__link):hover {
	text-decoration-thickness: 2px;
}

Where to add this

Recommended Additional CSS Appearance → Customize → Additional CSS, or your page builder's global CSS.
Child theme At the end of your child theme's style.css file.
A code snippets plugin As a CSS snippet set to load on the front end.

Many themes show links in a different colour only. People with colour blindness or low vision can miss them completely, which fails WCAG 1.4.1 (Use of Colour). Underlining links in body text fixes that.

How it works

The rules underline links inside the post content area, for classic themes (.entry-content) and block themes (.wp-block-post-content). Buttons are left alone.

A thin underline set slightly below the text looks tidy, and it gets thicker on hover.

Things to watch

  • Navigation menus, headers and footers aren’t changed; links there are usually clear from their position.
  • If your theme uses a different content class, add it to the selectors.

How to test it

Open a post with links. They should be underlined, and buttons should look the same as before.

This website uses cookies to enhance your browsing experience and ensure the site functions properly. By continuing to use this site, you acknowledge and accept our use of cookies.

Accept All Accept Required Only