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 Universal Selector

CSS Selectors

CSS Universal Selector

Use the universal selector deliberately for box-sizing resets, scoped defaults, and namespace-aware matching without applying unnecessary rules everywhere.

The CSS Universal Selector is used to select all elements on a webpage.
It is represented by an asterisk (*) and applies styles to every HTML element, unless overridden by more specific selectors.

This selector is often used for:

  • Resetting default browser styles
  • Applying global styling

Syntax for Global Selector

css

* {
    property: value;
}

Example of Global Selector

css

* {
    margin: 0;
    padding: 0;
}

👉 This removes default spacing from all elements.

Attributes

PropertyDescriptionExample
marginControls outer spacingmargin: 0;
paddingControls inner spacingpadding: 0;
box-sizingDefines box model calculationbox-sizing: border-box;
font-familySets font for all elementsfont-family: Arial;
colorSets default text colorcolor: black;

Scope broad matches

The universal selector has zero type specificity, but it can still match a large number of elements. A scoped reset such as .component, .component *, .component *::before, .component *::after is often safer than changing every node on the page. Remember that * matches elements, not pseudo-elements, so pseudo-elements must be listed explicitly when they need the same box-sizing rule. The supporting concepts are explained in Box Sizing and CSS Specificity.

Example

Global Selector Complete Example

html

<!DOCTYPE html>
<html>
<head>
    <title>CSS Universal Selector</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        h1 {
            color: blue;
        }

        p {
            color: green;
            padding: 10px;
        }
    </style>
</head>
<body>

    <h1>Universal Selector Example</h1>

    <p>This paragraph has no default margin.</p>
    <p>Spacing is controlled using CSS.</p>

</body>
</html>

Browser Support

Feature
Chrome
Edge
Firefox
Safari
Universal selector11211

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

Notes

  • The universal selector targets every element
  • Useful for creating a CSS reset
  • Can impact performance if overused in large projects
  • Often combined with other selectors for better control
  • Lower specificity compared to class and ID selectors

Conclusion

The CSS Universal Selector is a powerful tool for applying global styles across a webpage. It is especially useful for resetting default browser styles and ensuring consistent layout behavior.

PreviousCSS ID SelectorNextCSS Group Selector