Bootstrap button and text inline example

Hi Friends 👋,

Welcome To aGuideHub! ❤️

In this tutorial, we will learn how to create button and text inline in bootstrap.

To create a bootstrap button you have to use at least 2 classes:

  • btn- The btn class provides the basic structure to the button, like padding, border, border-radius, etc
  • btn-*- The classes like btn-primary, btn-danger, btn-success, etc specifies color, background-color and border-color to the button. Which gives different look to the button. Here, we will use .btn class to make a button in bootstrap.

Table of contents

  • Includes bootstrap view
  • Includes bootstrap library
  • Define its class name

This article will guide you to adding button and text inline in Bootstrap with example.

Step 1: Includes bootstrap view

To ensure proper rendering and touch zooming for all devices, add the responsive viewport meta tag to your <head>.

    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

Step 2: Includes bootstrap library

First of all, load the Bootstrap framework CSS into the head tag of your webpage.

<!-- Bootstrap CSS -->
   <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
    <script defer src="https://use.fontawesome.com/releases/v5.0.6/js/all.js"></script>
    <link rel="stylesheet" href="css/stylesheet.css">

Step 3: Define its class name

After that, create the badge over icon with a class name .d-inline-block.

    <h1> Bootstrap button and text inline example</h1>
    <div class="col-sm-8">
        <h4 class="d-inline-block">Edit Post</h4>
        <button type="button" class="btn btn-primary">Add New</button>
    </div>

Example.

Let’s look at the following example to understand how it basically works:

<!doctype html>
<html lang="en">

<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
        integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
    <script defer src="https://use.fontawesome.com/releases/v5.0.6/js/all.js"></script>
    <title> Bootstrap </title>
<style>
    h1{
        color: rgb(201, 25, 25);
       padding-bottom: 10pt;
    }
</style>
</head>

    <h1> Bootstrap button and text inline example</h1>
    <div class="col-sm-8">
        <h4 class="d-inline-block">Edit Post</h4>
        <button type="button" class="btn btn-primary">Add New</button>
    </div>
</body>

</html>

Check the output of the above code example.

Bootstrap, Text, Inline

All the best 👍