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 2D Transform

CSS Animations & Transitions

CSS 2D Transform

CSS 2D Transform allows you to modify an element's appearance on a two-dimensional plane using the X and Y axes.

CSS 2D Transform allows you to modify an element's appearance on a two-dimensional plane (X and Y axes).

With 2D transforms, you can:

  • Move elements horizontally or vertically
  • Rotate elements
  • Resize elements
  • Skew elements

Unlike normal positioning methods, transforms change the visual appearance of an element without affecting surrounding elements. The supporting concepts are explained in CSS Transform and CSS Transitions.

2D transforms are commonly used for:

  • Hover effects
  • Buttons
  • Cards
  • Image galleries
  • Interactive UI components

Syntax

2D Transform Syntax

css

selector {
    transform: function(value);
}

2D Transform Example

css

.box {
    transform: translateX(50px);
}

Moves the element 50px to the right.

Attributes

FunctionDescriptionExample
translateX()Moves horizontallytranslateX(50px)
translateY()Moves verticallytranslateY(30px)
rotate()Rotates elementrotate(45deg)
scaleX()Changes widthscaleX(1.5)
scaleY()Changes heightscaleY(1.5)
skewX()Tilts horizontallyskewX(20deg)
skewY()Tilts verticallyskewY(20deg)

Order changes the result

Transform functions are applied as a list, and changing their order changes the coordinate system used by later functions. Translating and then rotating is not equivalent to rotating and then translating. Set transform-origin when the pivot matters, and verify focus outlines and clickable regions after large visual movement so the interaction still matches what users see.

Example

CSS 2D Transform Complete Example

html

<!DOCTYPE html>
<html>
<head>
    <title>CSS 2D Transform Example</title>
    <style>
        .box {
            width: 150px;
            height: 150px;
            background-color: lightblue;
            margin: 50px;
            transform: translateX(50px) rotate(15deg);
        }
    </style>
</head>
<body>
    <div class="box"></div>
</body>
</html>

Browser Support

Feature
Chrome
Edge
Firefox
Safari
2D transforms3612169

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

Notes

Move Horizontally

Move Horizontally

css

transform: translateX(100px);

Moves element to the right.

Move Vertically

Move Vertically

css

transform: translateY(50px);

Moves element downward.

Rotate

Rotate

css

transform: rotate(45deg);

Rotates element clockwise.

Scale Width

Scale Width

css

transform: scaleX(2);

Doubles element width.

Scale Height

Scale Height

css

transform: scaleY(2);

Doubles element height.

Skew Horizontally

Skew Horizontally

css

transform: skewX(20deg);

Tilts element sideways.

Skew Vertically

Skew Vertically

css

transform: skewY(20deg);

Tilts element vertically.

Common 2D Transform Functions

FunctionEffect
translateX()Horizontal movement
translateY()Vertical movement
rotate()Rotation
scaleX()Width scaling
scaleY()Height scaling
skewX()Horizontal tilt
skewY()Vertical tilt

Conclusion

CSS 2D Transform provides a powerful way to move, rotate, resize, and skew elements on a two-dimensional plane. These transformations are widely used in modern web interfaces to create engaging visual effects and interactive user experiences.

PreviousCSS TransformNextCSS 3D Transform