← Back to Bootstrap Course | Chapter 4: Colors & Spacing | Lesson 2 of 7

Text के रंग

Text colour utilities text colour करती हैं और accessible contrast के लिए background utilities के साथ अच्छी तरह pair होती हैं।

In this page:

  1. Text Colors
Syntax
markup
<p class="text-primary">text</p>
<p class="text-danger-emphasis">text</p>
<p class="text-body-secondary">text</p>

Text Colors

Same theme colours text-* classes की तरह available हैं, stronger contrast के लिए -emphasis variants और neutral shades के लिए text-body-* के साथ। Coloured backgrounds पर contrast fix करने के लिए text-white या text-dark इस्तेमाल करें। text-opacity-* colour soften करता है।

Note: Contrast check करें; white पर text-warning पढ़ना मुश्किल है।

उदाहरण: Text colors

markup
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="p-3">
<div class="container">
  <p class="text-primary">text-primary</p>
  <p class="text-danger-emphasis">text-danger-emphasis</p>
  <div class="bg-dark p-2"><span class="text-white">white on dark</span> <span class="text-white text-opacity-50">50% opacity</span></div>
</div>
</body>
</html>
Live Example
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. white पर yellow जैसा Low contrast
  2. जहाँ dark mode support matter करे वहाँ text-muted इस्तेमाल करना
  3. कई colours mix करना
चैप्टर सारांश
  • text-{theme} text colour करता है
  • -emphasis variants contrast add करते हैं
  • text-white और text-dark contrast fix करते हैं
  • text-opacity text soften करता है
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.