WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

Bootstrap 4 - Badges


Bootstrap 4 uses box lessons to wrap the page's contents. It includes box classes

  • .Box − It represents a fixed width container.

  • .Container-fluid − It represents a complete width box.

Append and spotlight extra information to a string of text with a stylized badge.

Contextual Badges

You can trade the colour of badge through the use of contextual elegance as proven in the example under −

<html lang = "en">
   <head>
      <!-- Meta tags -->
      <meta charset = "utf-8">
      <meta name = "viewport" content = "width = device-width, preliminary-scale = 1, reduce-to-match = no">
      
      <!-- Bootstrap CSS -->
      <hyperlink rel = "stylesheet" 
         href = "https://stackpath.Bootstrapcdn.Com/bootstrap/four.1.3/css/bootstrap.Min.Css" 
         integrity = "sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" 
         crossorigin = "nameless">
      
      <title>Bootstrap four Example</name>
   </head>
   
   <body>
      <div magnificence = "container">
         <h2>Contextual Badges</h2>
         <span elegance = "badge badge-primary">Primary Badge</span>
         <span elegance = "badge badge-secondary">Secondary Badge</span>
         <span class = "badge badge-achievement">Success Badge</span>
         <span class = "badge badge-risk">Danger Badge</span>
         <span elegance = "badge badge-warning">Warning Badge</span>
         <span elegance = "badge badge-info">Info Badge</span>
         <span class = "badge badge-mild">Light Badge</span>
         <span magnificence = "badge badge-dark">Dark Badge</span>
      </div>
      
      <!-- jQuery first, then Popper.Js, then Bootstrap JS -->
      <script src = "https://code.Jquery.Com/jquery-3.Three.1.Narrow.Min.Js" 
         integrity = "sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" 
         crossorigin = "anonymous">
      </script>
      
      <script src = "https://cdnjs.Cloudflare.Com/ajax/libs/popper.Js/1.14.3/umd/popper.Min.Js" 
         integrity = "sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" 
         crossorigin = "anonymous">
      </script>
      
      <script src = "https://stackpath.Bootstrapcdn.Com/bootstrap/four.1.Three/js/bootstrap.Min.Js" 
         integrity = "sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" 
         crossorigin = "nameless">
      </script>
      
   </body>
</html>
It will produce the following end result −

Pill Badges

You could make corners of the badge more rounded via the usage of .Badge-tablet class as shown in the beneath instance −

Example

<html lang = "en">
   <head>
      <!-- Meta tags -->
      <meta charset = "utf-8">
      <meta name = "viewport" content material = "width = device-width, preliminary-scale = 1, reduce-to-in shape = no">
      
      <!-- Bootstrap CSS -->
      <link rel = "stylesheet" 
         href = "https://stackpath.Bootstrapcdn.Com/bootstrap/four.1.3/css/bootstrap.Min.Css" 
         integrity = "sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" 
         crossorigin = "nameless">
      
      <name>Bootstrap 4 Example</name>
   </head>
   
   <body>
      <div elegance = "container">
         <h2>Pill Badges</h2>
         <span elegance = "badge badge-tablet badge-number one">Primary Badge</span>
         <span class = "badge badge-tablet badge-secondary">Secondary Badge</span>
         <span magnificence = "badge badge-tablet badge-success">Success Badge</span>
         <span elegance = "badge badge-pill badge-risk">Danger Badge</span>
         <span magnificence = "badge badge-tablet badge-caution">Warning Badge</span>
         <span class = "badge badge-pill badge-data">Info Badge</span>
         <span magnificence = "badge badge-pill badge-light">Light Badge</span>
         <span class = "badge badge-pill badge-dark">Dark Badge</span>
      </div>
      
      <!-- jQuery first, then Popper.Js, then Bootstrap JS -->
      <script src = "https://code.Jquery.Com/jquery-3.3.1.Narrow.Min.Js" 
         integrity = "sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" 
         crossorigin = "anonymous">
      </script>
      
      <script src = "https://cdnjs.Cloudflare.Com/ajax/libs/popper.Js/1.14.3/umd/popper.Min.Js" 
         integrity = "sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" 
         crossorigin = "nameless">
      </script>
      
      <script src = "https://stackpath.Bootstrapcdn.Com/bootstrap/four.1.3/js/bootstrap.Min.Js" 
         integrity = "sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" 
         crossorigin = "nameless">
      </script>
      
   </frame>
</html>
It will produce the following end result −

Badge inner an Element

You can use badge interior a button as proven in the under instance −

<html lang = "en">
   <head>
      <!-- Meta tags -->
      <meta charset = "utf-8">
      <meta call = "viewport" content material = "width = tool-width, initial-scale = 1, shrink-to-suit = no">
      
      <!-- Bootstrap CSS -->
      <hyperlink rel = "stylesheet" 
         href = "https://stackpath.Bootstrapcdn.Com/bootstrap/4.1.3/css/bootstrap.Min.Css" 
         integrity = "sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" 
         crossorigin = "anonymous">
      
      <name>Bootstrap 4 Example</name>
   </head>
   
   <frame>
      <div magnificence = "box">
         <h2>Badge internal a Button</h2>
         <button kind = "button" elegance = "btn btn-info">
            Home <span magnificence = "badge badge-light">26</span>
         </button>
         
         <button kind = "button" magnificence = "btn btn-information">
            Messages <span class = "badge badge-light">19</span>
         </button>
      </div>
      
      <!-- jQuery first, then Popper.Js, then Bootstrap JS -->
      <script src = "https://code.Jquery.Com/jquery-3.Three.1.Narrow.Min.Js" 
         integrity = "sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" 
         crossorigin = "nameless">
      </script>
      
      <script src = "https://cdnjs.Cloudflare.Com/ajax/libs/popper.Js/1.14.3/umd/popper.Min.Js" 
         integrity = "sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" 
         crossorigin = "anonymous">
      </script>
      
      <script src = "https://stackpath.Bootstrapcdn.Com/bootstrap/four.1.3/js/bootstrap.Min.Js" 
         integrity = "sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" 
         crossorigin = "nameless">
      </script>
      
   </body>
</html>

It will produce the following result −

Output