WordPress菜单栏标签CSS word-spacing属性失效问题求助
Hey Ben, let's dig into why your word-spacing property isn't showing up visually even though DevTools says it's applied. Here are the most common fixes to try:
Check if your menu text uses regular spaces
Sometimes WordPress themes or editors sneak in non-breaking spaces ( ) instead of standard spaces.word-spacingonly affects regular spaces (U+0020), so if your menu items use , the property won't kick in. Verify this by inspecting the menu link's HTML in DevTools—look for instead of a plain space. If that's the case, edit your menu in WordPress admin to swap those out for regular spaces.Target the actual text container (if there's a child element)
A lot of WordPress themes wrap menu link text in a<span>or other child element for styling. If youratag has a nested span, your current CSS is applyingword-spacingto the parent link instead of the text itself. Update your selector to target the child element directly:.main-navigation .main-menu > li > a span { color: white; font-weight: normal; font-family: maiandra_gd_regular, verdana, sans-serif; margin: 0; word-spacing: 0.1em; }Test with a larger value first
0.1emis a tiny spacing—depending on your font size, it might be too subtle to notice. Try temporarily settingword-spacing: 0.5emto see if you can spot the difference. If that works, you can adjust back to your desired smaller value once you confirm the property is applying correctly.Check for conflicting CSS properties
Make sure no other styles are overriding or messing withword-spacing. For example,letter-spacingaffects character spacing (not word spacing) but could make it harder to see the word spacing change. Also, check ifwhite-spaceis set tonowraporpreon the link element—these can alter how word spacing renders. Use DevTools' "Computed" tab to see the final applied styles for the element.
If none of these work, you can try adding !important as a temporary test to rule out specificity issues (though it's best to avoid using !important long-term if you can fix the selector specificity instead):
.main-navigation .main-menu > li > a { color: white; font-weight: normal; font-family: maiandra_gd_regular, verdana, sans-serif; margin: 0; word-spacing: 0.1em !important; }
内容的提问来源于stack exchange,提问作者Ben Viatte

