Add a title to any heading element in the Bootstrap 4 card

BootstrapWeb DevelopmentCSS Framework

To add a title to any heading element in Bootstrap card, use the card-title class −

<h4 class="card-title">
  Top Universities
</h4>

The card-title class comes inside the card class in Bootstrap −

<div class="card-body">
  <h4 class="card-title">Top Universities</h4>
  <p class="card-text">Stanford</p>
  <p class="card-text">Oxford</p>
</div>

Example

Live Demo

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Bootstrap Example</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
  </head>

<body>
  <div class="container">
    <div class="card">
      <div class="card-body">
        <h4 class="card-title">Top Universities</h4>
        <p class="card-text">Stanford</p>
        <p class="card-text">Oxford</p>
      </div>
    </div>
  </div>

</body>
</html>
raja
Published on 15-Jul-2018 10:53:19
Advertisements