How to use anchor tag in bootstrap?
April 28, 2022Hi Friends 👋,
Welcome To aGuideHub! ❤️
Today, I am going to show you. How to use anchor tag in bootstrap with code example.
Here, we will use (<a>)
tag to make a link use anchor tag in bootstrap.
In this tutorial, Learn how to create an anchor link button with Bootstrap. The short answer is: use the anchor element (<a>)
and add the Bootstrap class .btn
in combination with the Bootstrap button contextual classes (like .btn-primary)
.
To create an anchor link button, you can have to use the <a>
element. After that, add the Bootstrap class .btn
in combination with the .btn-primary
. The second class is a Bootstrap contextual class that is useful to add look and feel to the anchor link button.
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">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet"/>
<title></title>
<style>
a.btn {border-radius: .25rem; border: 1px solid transparent; padding: .5rem 1rem; color: #fff; }
a.btn:hover { border-radius: .25rem; }
</style>
</head>
<body>
<div class="text-center">
<p>To create a new document, select File -> New from the bar along the top of the screen before editing the settings in the window that comes up to customize the new file.</p>
<a class="btn btn-primary" target="_blank" href="/blog/how-to-add-new-page-in-photoshop/">Click Me</a>
<!-- Option 1: Bootstrap Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
</body>
</html>
Check the output of the above code example.
All the best 👍