Premium Only Content

Learn CSS: Universal Day 16 | Selector and Inheritance Selector
Visit - www.skyhighes.com
Universal Selector and Inheritance Selector in CSS
In CSS, selectors are used to target specific elements on your web page and apply styles to them. Two fundamental types of selectors are:
1. Universal Selector:
Represented by the asterisk (*) symbol.
Applies styles to all elements on the page.
Has the highest specificity level, overriding all other selectors.
Example:
CSS
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
Use code with caution. Learn more
This code will set the margin, padding, and box-sizing of all elements on the page to zero.
Advantages:
Saves time by applying styles to all elements at once.
Useful for resetting default browser styles.
Disadvantages:
Can be difficult to override if you need to apply different styles to specific elements.
Can lead to unexpected results if not used carefully.
2. Inheritance Selector:
Selects all descendant elements of a particular element.
Uses the greater-than symbol (>) to separate the parent element from the descendant element.
Example:
CSS
body > h1 {
font-size: 2em;
text-align: center;
}
Use code with caution. Learn more
This code will set the font size to 2em and text-align to center for all h1 elements that are direct children of the body element.
Advantages:
Organizes styles by element hierarchy.
Makes your CSS code more maintainable and easier to understand.
Disadvantages:
Can be verbose for deeply nested elements.
Can be difficult to override if you need to apply different styles to specific descendant elements.
-
LIVE
EricJohnPizzaArtist
43 minutes agoAwesome Sauce PIZZA ART LIVE Ep. #45: Tony the Cat!
33 watching -
LIVE
OhHiMark1776
2 hours ago🟢04-27-25 ||||| Halo Multiplayer Rumble: No. 13 ||||| Halo MCC (2019)
117 watching -
15:05
Stephen Gardner
1 day ago🔥BREAKING: Trump HAMMERS Zelensky after Kicking France's Macron from meeting about Ukraine!
74.2K293 -
LIVE
AirCondaTv Gaming
2 hours agoSchedule I & Halo - Hustle Hard to Play Hard Later. May the TBags Flow Collab)
6 watching -
LIVE
vivafrei
10 hours agoEp. 261: Criminal Judges ARRESTED! Election in Canada! Santos Sentenced! RFK Jr. & Autism & MORE!
25,267 watching -
LIVE
Nerdrotic
2 hours agoDiscoveries From Graham Hancock's "Fight for the Past" | Forbidden Frontier 099
1,070 watching -
53:29
Professor Nez
4 hours ago🚨🇺🇸 President Trump MAKES HISTORY! The REAL Story of His First 100 Days!
20.5K67 -
17:01
DeVory Darkins
21 hours ago $36.87 earnedDemocrats HUMILIATE AOC as Trump drops bombshell order
49.5K135 -
LIVE
Amish Zaku
2 hours agoRumble Spartans "The One Year" Event
131 watching -
9:20
Tactical Advisor
1 day agoNew Shadow 2 Carry | CZ Compact Upgrade (FIRST LOOK)
68.9K19