💡 Tip: Login now to track your course progress and unlock your downloadable certificates instantly!

CSS Universal Selector

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
* {
    property: value;
}
Example of Global Selector
* {
    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;

Example

Global Selector Complete Example
<!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>

Output

Browser Output

All elements will have no default margin and padding
Layout becomes more consistent across browsers
Heading will appear in blue
Paragraphs will appear in green with padding

Browser Support

Chrome
Chrome
Firefox
Firefox
Edge
Edge
Safari
Safari
Opera
Opera
IE
IE9+
✅Yes✅Yes✅Yes✅Yes✅Yes✅Yes

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.

Sign In Form

User your email and password to singn in

Don’t have an account, signup here : 

HTML5 & CSS3

Tools and Tutorials

Want a Website

Want a website for your business ?

Please fill out the details below, so we can reach out to you.

Registration Form

Signup to track your record and much more.

We have sent you an email with a registration link. Please click the link to verify your email address, or enter the 6-digit OTP provided in the email.

Didn't receive the OTP. Regenerate OTP Resend