← Back to Bootstrap Course | Chapter 3: Typography | Lesson 5 of 7

Text के रंग

Text colour utilities text में Bootstrap के theme colours apply करती हैं।

In this page:

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

Text Colors

.text-primary, .text-success, .text-danger, और .text-warning जैसी classes theme इस्तेमाल करते हुए text colour करती हैं। .text-body-secondary और .text-body-emphasis light और dark modes के हिसाब से adapt होते हैं। एक accessible text colour के साथ एक background pair करने के लिए .text-bg-* इस्तेमाल करें।

Note: अकेला Colour meaning carry नहीं करना चाहिए; text या icons भी add करें।

उदाहरण: 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">Primary</p>
  <p class="text-success">Success</p>
  <p class="text-danger">Danger</p>
  <p class="text-warning-emphasis bg-warning-subtle p-1">Warning emphasis on subtle background</p>
  <p class="text-body-secondary">Secondary body text</p>
  <span class="badge text-bg-dark">text-bg-dark</span>
</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. state convey करने के लिए सिर्फ colour पर depend करना
  2. low contrast combinations इस्तेमाल करना
  3. version 5.3 में text-body-secondary की बजाय text-muted इस्तेमाल करना
चैप्टर सारांश
  • text-primary, success, danger, warning jaise classes मिलती हैं
  • text-body-secondary dark mode के हिसाब से adapt होता है
  • text-bg-* colours pair करता है
  • सिर्फ colour पर depend न करें
🔒

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.