CHAPTER 55

CSS Transitions

Learn how transitions create smooth changes between CSS property values.

01. What is CSS Transitions?

Transitions animate a property change from one value to another.
transition-duration controls how long the change takes.
Transitions are commonly combined with hover states.

02. Syntax

selector { transition: property duration timing-function; }

03. Example

CSS / HTML Example AIFA Coding Lab
<!DOCTYPE html>
<html>
<head>
<style>
button {
    padding: 14px 25px;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 10px;
    transition: .3s;
}

button:hover {
    background: #06b6d4;
    transform: translateY(-3px);
}
</style>
</head>
<body>

<button>Hover Me</button>

</body>
</html>

04. Important Points

✓ transition controls smooth property changes.
✓ duration controls animation time.
✓ Timing functions control the speed curve.
✓ Transitions are ideal for small UI interactions.

05. Common Mistakes

⚠ Using extremely long transitions.
⚠ Animating too many properties unnecessarily.
⚠ Creating effects that distract users.

06. Real World Use

Transitions are used in buttons, cards, navigation links, forms, menus and interactive components.

Ready to Practice? 🚀

Open the AIFA CSS Editor and practice this chapter live.

Try It Yourself →
Practice Exercise

Create a Smooth Button

Create a button whose background and position change smoothly on hover.