HTML5ANDCSS3 logoHTML5ANDCSS3Tools and Tutorials
  • Insights
  • Verify Certificate
HTML5ANDCSS3 logoHTML5ANDCSS3Tools and Tutorials
HTML5ANDCSS3 logoHTML5ANDCSS3Tools and Tutorials

HTML5andCSS3.org helps developers learn modern frontend skills with practical tutorials, production-ready snippets, and fast web tools built for everyday coding.

Quick Links

  • About Us
  • Contact Us
  • Privacy Policy
  • Copyright
  • Disclaimer

Top Tools

  • Try It Editor
  • JSON Formatter
  • CSS Minifier
  • HTML Minifier
  • Base64 Encoder / Decoder

Contact

  • business@html5andcss3.org
Newsletter

Learn at your own pace, practice with useful tools, and build websites you're proud of.

© 2011-2026 html5andcss3.org. All rights reserved.

How to Use

CSS Tutorial

CSS Introduction

What is CSSCSS SyntaxHow to Add CSSCSS Comments

CSS Foundations

Cascade & InheritanceCSS SpecificityCSS UnitsBox SizingCSS VariablesCSS Math Functions

CSS Selectors

CSS Element SelectorCSS Class SelectorCSS ID SelectorCSS Universal SelectorCSS Group SelectorCSS CombinatorsCSS Attribute SelectorsCSS Pseudo ClassesCSS Pseudo Elements

CSS Colors and Backgrounds

CSS ColorsCSS HEX ColorsCSS RGB ColorsModern ColorsCSS Background ColorCSS Background ImageLayered Backgrounds

CSS Text & Fonts

CSS Text ColorCSS Text AlignmentCSS Text DecorationCSS Font FamilyCSS Font SizeWeb Fonts & TypographyText Wrapping

CSS Box Model

CSS MarginCSS PaddingCSS BorderCSS OutlineCSS Width and Height

CSS Layout

Normal FlowCSS DisplayCSS PositionAnchor PositioningCSS FloatCSS OverflowCSS Z-indexIntrinsic SizingAspect Ratio & Object FitMulti-column Layout

CSS Flexbox

Flex ContainerFlex DirectionJustify ContentAlign ItemsFlex WrapFlex Item Sizing

CSS Grid

CSS Grid ContainerCSS Grid ColumnsCSS Grid RowsCSS Grid GapCSS Grid Layout ExampleGrid PlacementGrid AreasCSS Subgrid

CSS Lists, Tables & Forms

CSS ListsCSS TablesCSS Form StylingCSS Input Fields

CSS Effects

CSS ShadowsCSS GradientsCSS FiltersCSS OpacityClipping & MaskingBlending & BackdropScroll Snap

CSS Animations & Transitions

CSS TransformCSS 2D TransformCSS 3D TransformCSS TransitionsEntry & Exit TransitionsCSS AnimationsScroll AnimationsView TransitionsMotion Paths

CSS Responsive Design

CSS Media QueriesResponsive LayoutMobile First DesignContainer QueriesPreference Media QueriesFeature Queries

Modern CSS Authoring

Cascade LayersNesting & ScopeLogical PropertiesGenerated Content

CSS Accessibility

Accessible CSSCSS ThemingModern Form StylingCSS User Interface

CSS Output & Performance

Print StylesCSS PerformanceCSS ArchitectureDebugging CSS

CSS Reference

CSS At-rulesCSS FunctionsCSS Tutorial PDF

CSS Projects

Responsive CSS Project
  1. Home
  2. /
  3. Tutorials
  4. /
  5. CSS Tutorial
  6. /
  7. CSS Transitions

CSS Animations & Transitions

CSS Transitions

The CSS Transition property allows you to create smooth animations between property changes.

Without transitions, style changes happen instantly. With transitions, changes occur gradually over a specified duration, creating a more polished user experience. The supporting concepts are explained in Entry & Exit Transitions and CSS Animations.

Transitions are commonly used for:

  • Button hover effects
  • Menu interactions
  • Image effects
  • Card animations
  • Modern UI components

Syntax

Transition Syntax

css

selector {
    transition: property duration timing-function delay;
}

Transition Example

css

button {
    transition: background-color 0.3s ease;
}

Smoothly changes the button's background color over 0.3 seconds.

Attributes

PropertyDescriptionExample
transitionShorthand propertytransition: all 0.3s ease;
transition-propertySpecifies which property changestransition-property: width;
transition-durationSets animation timetransition-duration: 1s;
transition-timing-functionControls animation speed curvetransition-timing-function: ease;
transition-delayDelays animation starttransition-delay: 0.5s;

Example

CSS Transitions Complete Example

html

<!DOCTYPE html>
<html>
<head>
    <title>CSS Transitions Example</title>
    <style>
        .button {
            background-color: #007acc;
            color: white;
            padding: 12px 24px;
            border: none;
            cursor: pointer;
            transition: background-color 0.4s ease;
        }
        .button:hover {
            background-color: #005999;
        }
    </style>
</head>
<body>
    <button class="button">
        Hover Me
    </button>
</body>
</html>

Browser Support

Feature
Chrome
Edge
Firefox
Safari
transition2612169

Versions show the first stable desktop release with unprefixed support. Data source: MDN Browser Compatibility Data 8.0.8.

Notes

Transition Multiple Properties

Multiple Property Transition

css

transition:
    background-color 0.3s ease,
    transform 0.3s ease;

Animates both color and transform changes.

Width Transition

Width Transition

css

.box {
    width: 100px;
    transition: width 0.5s ease;
}
.box:hover {
    width: 200px;
}

Smoothly expands the width.

Timing Functions

ValueEffect
easeSlow start and end
linearConstant speed
ease-inSlow start
ease-outSlow end
ease-in-outSlow start and end

Transition All Properties

Transition All Properties

css

transition: all 0.3s ease;

Applies transitions to all animatable properties.

Common Transition Example

Common Transition Example

css

.card {
    transition: transform 0.3s ease;
}
.card:hover {
    transform: scale(1.05);
}

Creates a smooth zoom effect.

Conclusion

CSS Transitions provide an easy way to create smooth and professional visual effects when element properties change. By controlling duration, timing, and delays, transitions enhance user experience and make interfaces feel more responsive and interactive.

PreviousCSS 3D TransformNextEntry & Exit Transitions