How to Underline in WordPress: Shortcuts and CSS

Underline drawn beneath WordPress text

To underline text in WordPress, select the words inside a Paragraph or Heading block and press Ctrl + U on Windows or Command + U on a Mac. Work in the visual editor, where you can see the formatted text. You do not need to switch to HTML or install a plugin for this shortcut.

Use underlining sparingly: readers often expect underlined words to be links. For ordinary emphasis, bold or italic text is usually clearer.

Underline selected words in the block editor

  1. Open the post or page you want to edit.
  2. Click inside a Paragraph or Heading block and select only the words you want to underline. Select the text itself, rather than the entire block.
  3. Press Ctrl + U on Windows or Command + U on macOS.
  4. Preview the page to check the result, then save or update it. To remove the formatting, select the same words and press the shortcut again.

The editor does not need to show a separate Underline toolbar button for the shortcut to work. WordPress lists the shortcut in its official block-editor keyboard reference.

Underline an entire block with typography settings

Some blocks and themes expose a Decoration control under the block’s Typography settings. If it is available, choose Underline to style the block’s text, or Normal to remove that block-level decoration. Available controls vary by block and theme; use the keyboard shortcut for individual words.

This control changes appearance. It does not turn text into a link. If readers should be able to click the text, add a real link using the Link control instead. See WordPress typography settings for the available controls.

Use HTML and CSS when you need precise control

For a small, self-contained piece of HTML, add a Custom HTML block and use a span with a text-decoration style:

<p>This sentence contains <span style="text-decoration: underline;">underlined text</span>.</p>

The underline applies only to the words inside the span. Preview the block and the published page. A Custom HTML block is useful for markup you maintain directly; it is not necessary for an ordinary paragraph you want to edit visually.

If you use the Classic Editor, the equivalent code belongs in its Text tab. Keyboard formatting belongs in its Visual tab. These are different interfaces: the block editor does not use the Classic Editor’s Visual/Text tabs.

For a reusable style, use a descriptive class such as htwp-underline and add the rule to your site’s supported custom CSS area or a child-theme stylesheet:

.htwp-underline {
    text-decoration: underline;
}

Apply that class to the specific element you want to style. Do not apply a rule to every paragraph, heading, or link merely to format one phrase. A theme update can overwrite edits made directly to the parent theme’s stylesheet.

What to check if the underline does not appear

  1. Make sure the cursor is inside editable text and the words are selected. A shortcut pressed outside the editor may trigger a browser action instead.
  2. Check whether you are editing a Code or Custom HTML block. Shortcuts there do not format the markup as if it were a visual paragraph.
  3. If the editor shows an underline but the page does not, preview the saved page and check whether your theme applies a conflicting text-decoration rule.
  4. If the underline returns after toggling the shortcut off, check the block’s Decoration setting and any custom CSS. Remove it at the level where it was added.

Do you need an underline plugin?

No plugin is needed for the core text shortcut. If you already use an editor-extension plugin, its controls may differ from the default editor. Follow that plugin’s current documentation instead of assuming its Classic Editor toolbar options also apply to the block editor.

Common questions

Does underlining improve SEO? Underlining is a presentation choice, not a ranking shortcut. Use meaningful headings, clear explanations, and helpful links to make the page easier to use.

Can I underline with Markdown underscores? A single underscore normally marks emphasis in Markdown; it is not a general underline command. Formatting in an embedded third-party service depends on that service and may not be editable from WordPress.

Should I use the HTML u element? For a purely visual underline, a CSS text-decoration rule makes the styling intent explicit. Use strong or em when the meaning is importance or emphasis, and a real anchor element when the text is a link.

For related formatting tasks, follow our guides to changing font size in WordPress and centering a title. Preview the combined changes on a narrow screen before publishing.

For related formatting, see changing font size in WordPress and centering a title or heading. Apply each change to the intended block and preview the public page.

Related Posts

5 Comments

  1. Hello,

    Thanks for this article. It is a great overview of underlining.

    One issue, though, is that since HTML 4, is deprecated, in its sense as denoting “underlining” (but it is not deprecated in its new sense, as the “unarticulated annotation”). And some SEO tools will report pages using under the heading “deprecated HTML” or some such similar phrase, to point out that may be used wrongly (that is, in its old sense).

    So if it’s underlining we want, we have to use some other method. And the method most commonly suggested is using in-line CSS with the tag, and using “text-decoration: underline” as the style. And this is what WordPress themselves do, when implementing “underline” in their Gutenberg block editor’s formatting options.

    So I’ll give an example from my one of my latest articles on “karma”. So in the sentence “…action sometimes may seem to be a causal factor…” I want to underline the word “seem”. So I select the word “seem” and then choose the “underline” item from the Down-Arrow menu (also called the “More” menu). And I then switch to WordPress’s Code Editor view to see what code they have generated:

    “…action sometimes may seem to be a causal factor…”

    I think this looks really “clumsy”, in terms of editability. So no longer is it easy to manually add underline in the HTML itself, but the result is also that the core text is much less easy to read, since the formatting tag is so long.

    A better way of doing it would be to define a CSS format called “myu” or something:

    #myu{text-decoration : underline;}

    and then one could use the following, more compact, and more readable, formatting in the text instead:

    “…action sometimes may seem to be a causal factor…”

    It’s still longer and clumsier than the original tag, but at least it is less “destructive” to the readability of the real text, in my opinion. So that will be my new underline format on my own website.

    Have a GREAT day!
    Chris Bocay

    1. Hello again,

      Well, WordPress *interpreted* my HTML examples above, so you cannot see what my original text said. So let me do it like this instead: I have replaced the “” tags with square brackets instead, to illustrate my code examples. I am hoping that this will show my code as it is.

      First, the code used by WordPress’s own Block editor:

      “…action sometimes may [span style=”text-decoration: underline;”]seem[/span] to be a causal factor…”

      and then using the “myu” format:

      “…action sometimes may [span id=”myu”]seem[/span] to be a causal factor…”

      Thanks,
      Chris Bocay

      1. Hello Chris Bocay,

        I understand you were having issues with WordPress interpreting your HTML code examples in a previous communication. To illustrate your code examples, you have replaced the angle brackets with square brackets.

        You provided two examples of code, one using WordPress’s Block editor and another using the “myu” format. The code snippets include a span element with different attributes.

        In the first example, the span element has a style attribute with a value of “text-decoration: underline;”, which adds an underline to the text within the span element. In the second example, the span element has an id attribute with a value of “myu”.

        I hope this answers your question.

        Let me know if you have any further queries.

        Best Regards
        Shakeel

        1. Hello, Shakeel,

          Thanks for writing a reply, but I had no question. I understand what the code does (I mean, I am the one who proposed it in the first place!). Thanks anyway! Have a great day! — Chris

    2. Thank you again for your message and explanation of the issues related to underlining in HTML. I comprehend that the traditional HTML tag for underlining text has been deprecated since HTML 4, and using it may cause confusion for some SEO tools.

      You suggest using in-line CSS with the “text-decoration: underline” style to achieve underlining. WordPress also implements this method in their Gutenberg block editor’s formatting options.

      You provide an example of creating a CSS format called “myu” with the “text-decoration: underline” style, which would allow for more compact and readable formatting in the text.

      Thank you for sharing your thoughts on this topic, and I hope you have a great day too!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Subscribe to our Monthly Newsletter

Get monthly updates of WordPress tips, tricks, and tutorials in your email.

Thanks. You have successfully subscribed.