Skip to main content
Practice

What is a Button?

A button on a web page is an element that encourages users to click on it and helps perform various functions.

Buttons can carry out a wide range of functions.

For example, clicking a login button will log the user in, clicking a sign-up button will navigate to the sign-up page, and clicking a post creation button will navigate to the post creation page.

Buttons can be placed anywhere on a web page. Because they are used so frequently, buttons are often pre-designed and ready for use.


Button Example Code - html
<li>
<a class="nav-link btn btn-primary" href="#footer"
>Contact Us <i class="fas fa-arrow-right"></i
></a>
</li>
Button Example Code - css
.navbar .btn {
margin-right: 24px;
}

.fas.fa-arrow-right {
margin-left: 8px;
font-size: 14px;
}

/* Buttons */
.btn {
display: inline-block;
padding: 12px 32px;
border-radius: 30px;
text-transform: uppercase;
font-size: 14px;
transition: 0.3s;
}

.btn-primary {
background: var(--primary-color);
color: #000000;
}

.btn-secondary {
margin: 5px 0;
background-color: var(--bg-secondary);
color: var(--bg-primary);
}

Let's examine this code step by step to understand its composition.

Want to learn more?

Join CodeFriends Plus membership or enroll in a course to start your journey.