CHAPTER 62

CSS Buttons

Learn how to create attractive and responsive buttons using CSS.

01. What is CSS Buttons?

Buttons are important interactive elements in websites.
CSS can control button size, color, border, shadow and hover effects.
Good buttons should clearly communicate their purpose.

02. Syntax

button { padding: 12px 20px; border: none; border-radius: 8px; cursor: pointer; }

03. Example

CSS / HTML Example AIFA Coding Lab
<!DOCTYPE html>
<html>
<head>
<style>

.btn {
    padding: 13px 25px;
    border: none;
    border-radius: 10px;
    background: #2563eb;
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: .3s;
}

.btn:hover {
    background: #1d4ed8;
    transform: translateY(-2px);
}

</style>
</head>
<body>

<button class="btn">
    Enroll Now
</button>

</body>
</html>

04. Important Points

✓ Buttons should have enough clickable space.
✓ Use cursor: pointer for clickable buttons.
✓ Hover and focus states should be visible.
✓ Button text should clearly describe the action.

05. Common Mistakes

⚠ Making buttons too small.
⚠ Poor color contrast.
⚠ Removing focus indicators.
⚠ Using vague button labels.

06. Real World Use

Buttons are used for forms, admissions, purchases, navigation, login, registration and calls to action.

Ready to Practice? 🚀

Open the AIFA CSS Editor and practice this chapter live.

Try It Yourself →
Practice Exercise

Create a CTA Button

Create a premium 'Join Now' button with hover, focus and active effects.