0
0
BootstrapHow-ToBeginner · 3 min read

How to Use text-muted in Bootstrap for Muted Text Styling

Use the text-muted class in Bootstrap by adding it to any text element to make the text appear lighter and less prominent. This class applies a lighter gray color that helps de-emphasize text visually while keeping it readable.
📐

Syntax

The text-muted class is added directly to any HTML element containing text to apply a muted, lighter color style. It is a simple utility class provided by Bootstrap.

  • <tag class="text-muted">Your text</tag>: Adds muted styling to the text inside the tag.
  • tag can be any text container like p, span, small, div, etc.
html
<p class="text-muted">This text is muted using Bootstrap.</p>
Output
This text is muted using Bootstrap.
💻

Example

This example shows how to use text-muted on different text elements to make them appear lighter and less prominent compared to normal text.

html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Bootstrap text-muted Example</title>
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
  <div class="container mt-4">
    <h1>Normal Text</h1>
    <p>This is normal paragraph text.</p>
    <p class="text-muted">This paragraph uses <code>text-muted</code> to appear lighter.</p>
    <small class="text-muted">This small text is muted as well.</small>
  </div>
</body>
</html>
Output
A webpage with a heading 'Normal Text', a normal paragraph, a lighter gray paragraph, and small muted text below.
⚠️

Common Pitfalls

Common mistakes when using text-muted include:

  • Not including Bootstrap CSS, so the class has no effect.
  • Applying text-muted to elements that already have strong color styles, which can override the muted color.
  • Using text-muted on backgrounds with low contrast, making text hard to read.

Always ensure Bootstrap CSS is loaded and check color contrast for accessibility.

html
<!-- Wrong: No Bootstrap CSS linked, so text-muted does nothing -->
<p class="text-muted">This text will not appear muted without Bootstrap CSS.</p>

<!-- Right: Bootstrap CSS included -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<p class="text-muted">This text appears muted correctly.</p>
Output
First paragraph appears normal because no Bootstrap CSS is loaded; second paragraph appears lighter gray with Bootstrap CSS.
📊

Quick Reference

text-muted class applies a lighter gray color to text for de-emphasis.

  • Use on any text element: p, span, small, etc.
  • Requires Bootstrap CSS to work.
  • Helps improve visual hierarchy by making some text less prominent.
  • Check color contrast for readability and accessibility.

Key Takeaways

Add the class text-muted to any text element to make it appear lighter and less prominent.
Ensure Bootstrap CSS is included in your project for text-muted to work.
Avoid using text-muted on low-contrast backgrounds to keep text readable.
Use text-muted to create visual hierarchy by de-emphasizing less important text.
The class works on any text container like p, span, or small.