Why the Bold Button Uses <strong> Instead of <b> (And How to Change It)
Content
A common point of confusion for users of the Classic Editor is the behavior of the bold button. While the button is labeled with a B, it actually wraps the selected text in <strong> HTML tags rather than the older <b> tags. This article explains why this happens and provides a solution for users who need to change it.
Why <strong> and Not <b>?
The shift from the <b> tag to the <strong> tag was a deliberate decision made years ago across the web development landscape. The <b> tag was purely a visual element for bold styling. The <strong> tag, however, carries semantic meaning, indicating that the enclosed text is of strong importance.
This change aligns with modern web standards (like WCAG) which emphasize separating content structure from presentation. Screen readers and other assistive technologies can interpret <strong> to change the tone of voice, providing a better experience for users. While both tags typically render text as bold visually, <strong> is the more semantically correct choice.
When You Might Need to Change It Back
Despite the benefits of using <strong>, there are scenarios where a user might need the editor to output a <b> tag instead. The most common reason is a compatibility issue with another plugin or theme that specifically expects the older <b> tag for proper formatting or functionality.
How to Change <strong> to <b>
If you have determined that you must replace <strong> tags with <b> tags, you can do so by adding a small code snippet to your website. This snippet will filter the content and perform a simple text replacement.
Important: Always use a child theme or a code snippets plugin to add custom code. Never edit your theme's functions.php file directly without a backup.
function change_strong_to_b( $content ) {
$content = str_replace( 'strong>', 'b>', $content );
return $content;
}
add_filter( 'the_content', 'change_strong_to_b' );
add_filter( 'the_editor', 'change_strong_to_b' );
What this code does:
- It creates a function called
change_strong_to_bthat searches for allstrong>tags and replaces them withb>. - It then applies this function to two filters:
the_content(which affects the content displayed on your site) andthe_editor(which affects the content within the editor itself).
After adding this code, the bold button in the Classic Editor will output <b> tags, and any existing <strong> tags on your site will also be replaced.
A Final Note on Compatibility
While this code provides a quick fix, the ideal long-term solution is to contact the support for the other plugin or theme that is causing the conflict. They may be able to update their code to properly handle the modern <strong> tag, which is the web standard.
Related Support Threads Support
-
change to with the “B” buttonhttps://wordpress.org/support/topic/change-to-with-the-b-button/
-
‘Save draft’ and ‘Publish’ buttons change their names to english themselfshttps://wordpress.org/support/topic/save-draft-and-publish-buttons-change-their-names-to-english-themselfs/
-
Incorrect output of taghttps://wordpress.org/support/topic/incorrect-output-of-tag/
-
WCAG Level A and AA compliancehttps://wordpress.org/support/topic/wcag-level-a-and-aa-compliance/
-
Points trasfer to bold lettershttps://wordpress.org/support/topic/points-trasfer-to-bold-letters/