SlideShare a Scribd company logo
IN A ROCKET
Learn front-end development at rocket speed
CSS CSS FUNDAMENTALS
Pseudo-class
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
PSEUDO-CLASSES
With this code all a elements that have not yet been visited are shown in green.
A pseudo-class selects an element with a special state specified by a keyword.
a:link {color: green}
Syntax selector:pseudo-class {style properties}
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
TARGET &
LANG
UI ELEMENT
STATES
DYNAMIC
NEGATIONSTRUCTURAL
PSEUDO-CLASSES PSEUDO-CLASSES PSEUDO-CLASSES
PSEUDO-CLASSES PSEUDO-CLASSES
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
Dynamic 

pseudo-classes
:link

:visited

:hover

:active

:focus
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
PSEUDO-CLASSES / DYNAMIC / LINK STATES
Contact
a:link 

Represents links that have 

not yet been visited.
Contact
a:visited 

Styles for links that have been visited

(exists in the browser's history).
Contact
a:active 

Triggered when the user clicks the link or 

selects it with the keyboard's tab key.
CLICKED
Contact
a:hover 

Generally triggered when the user hovers over 

an element with the cursor (mouse pointer).
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
Dynamic 

pseudo-classes
:link

:visited

:hover

:active

:focus
How to remember them?
😍 LOVE
😤 HATE
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
PSEUDO-CLASSES / DYNAMIC
With this code all not visited links are shown in green.
Selects all links that have not yet been visited.
a:link {color: green}
Syntax selector:link {style properties}
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
HTML CSS
Browser
PSEUDO-CLASSES / DYNAMIC
<body>
<a href="#">Not visited.</a>
<a href="#">Visited.</a>
<a href="#">Hover.</a>
<a href="#">Active.</a>
<input type="text" name="zip" id="zip">
</body>
a:link { color: blue; }
a:visited { color: purple; }
a:hover { color: green; }
a:active { color: red; }
input:focus { color: orange; }
Web page title
index.html
Not visited.
Pressed
Visited. Hover. Active. Writing here...
READY TO USE CODE
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
TARGET &
LANG
UI ELEMENT
STATES
DYNAMIC
NEGATIONSTRUCTURAL
PSEUDO-CLASSES PSEUDO-CLASSES PSEUDO-CLASSES
PSEUDO-CLASSES PSEUDO-CLASSES
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
PSEUDO-CLASSES / TARGET & LANG
With this code the terms fragment identifier is shown in green.
Selects a fragment identifier that has a location within a resource.
h2:terms {color: green}
Syntax selector:target {style properties}
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
HTML CSS
Browser
PSEUDO-CLASSES / TARGET & LANG
<body>
<a href="#about">About.</a>
<a href="#terms">Terms.</a>
<h2 id="about">About our company</h2>
<h2 id="terms">Terms of use</h2>
</body>
h2:target { color: green; }
Web page title
index.html
- About.
- Terms.
About our company
Terms of use
READY TO USE CODE
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
PSEUDO-CLASSES / TARGET & LANG
With this code the paragraphs in English (en) are shown in green.
Selects elements based on the language they are determined to be in.
p:lang(en) {color: green}
Syntax selector:lang(lg) {style properties}
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
HTML CSS
Browser
PSEUDO-CLASSES / TARGET & LANG
<body>
<p lang="en"><q>To be, or not to be:
that is the question.</q></p>
<p lang="es"><q>En un lugar de la
Mancha, de cuyo nombre no quiero
acordarme...</q></p>
</body>
p:lang(en) > q { quotes: '201C' '201D'; }
p:lang(es) > q { quotes: '«' '»'; }
Web page title
index.html
“To be, or not to be: that is the question.”
«En un lugar de la Mancha, de cuyo nombre no quiero
acordarme...»
READY TO USE CODE
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
TARGET &
LANG
UI ELEMENT
STATES
DYNAMIC
NEGATIONSTRUCTURAL
PSEUDO-CLASSES PSEUDO-CLASSES PSEUDO-CLASSES
PSEUDO-CLASSES PSEUDO-CLASSES
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
PSEUDO-CLASSES / UI ELEMENT STATES
With this code only the enabled inputs are shown in green.
Selects any enabled element (it can be selected, clicked on, typed into, etc.).
input:enabled {color: green}
Syntax selector:enabled {style properties}
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
PSEUDO-CLASSES / UI ELEMENT STATES
With this code only the disabled inputs are shown in green.
Selects any disabled element.
input:disabled {color: green}
Syntax selector:enabled {style properties}
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
HTML CSS
Browser
PSEUDO-CLASSES / UI ELEMENT STATES
<body>
<form>
<label for="name">Name:</label>
<input type="text" id="name">
<label for="city">City:</label>
<input type="text" id="city" value="NYC"
disabled="disabled">
<input type="button" value="Submit">
</form>
</body>
input:enabled { color: green; }
input:disabled { color: gray; }
Web page title
index.html
Name:
City:
John Doe
NYC
READY TO USE CODE
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
PSEUDO-CLASSES / UI ELEMENT STATES
With this code only the checked inputs are shown in green.
Selects any radio, checkbox or option that is checked or toggled to an on state.
input:checked {color: green}
Syntax selector:checked {style properties}
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
HTML CSS
Browser
PSEUDO-CLASSES / UI ELEMENT STATES
<body>
<form>
<input type="radio" name="pay" id="cash">
<label for="cash">Cash</label>
<input type="radio" name="pay" id="card">
<label for="card">Card</label>
<input type="checkbox" name="nwslt" id="nwslt">
<label for="nwslt">Subscribe me!</label>
</form>
</body>
input[type=radio]:checked + label { color:
green; }
input[type=checkbox]:checked + label { color:
blue; }
Web page title
index.html
Cash Card Subscribe me!
READY TO USE CODE
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
TARGET &
LANG
UI ELEMENT
STATES
DYNAMIC
NEGATIONSTRUCTURAL
PSEUDO-CLASSES PSEUDO-CLASSES PSEUDO-CLASSES
PSEUDO-CLASSES PSEUDO-CLASSES
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
Structural 

pseudo-classes
:root
:empty

:first-child

:last-child

:nth-child()

:only-child

:first-of-type

:last-of-type

:nth-of-type()

:only-of-type
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
PSEUDO-CLASSES / STRUCTURAL
Selects an element that is the root of the document (in HTML, this is always the HTML element).
:root {color: green}
Syntax :root {style properties}
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
HTML CSS
Browser
PSEUDO-CLASSES / STRUCTURAL
<body>
<h2>Lorem ipsum dolor</h2>
<p>Nostrum similique veniam commodi sed esse earum
voluptatum corrupti at quam voluptates?</p>
<ul>
<li>Esse</li>
<li>Earum</li>
</ul>
</body>
:root { color: green; }
Web page title
index.html
Lorem ipsum dolor
Nostrum similique veniam commodi sed esse earum voluptatum
corrupti at quam voluptates?
• Esse
• Earum
READY TO USE CODE
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
HTML CSS
Browser
PSEUDO-CLASSES / STRUCTURAL
<body>
<h2>Lorem ipsum dolor</h2>
<p>Nostrum similique veniam commodi sed esse
earum voluptatum corrupti at quam voluptates?
</p>
</body>
:root {
--color-primary: blue;
--color-secondary: gray;
}
p {
background: var(--color-secondary);
color: var(--color-primary);
}
Web page title
index.html
Lorem ipsum dolor
Nostrum similique veniam commodi sed esse earum voluptatum
corrupti at quam voluptates?
READY TO USE CODE
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
Structural 

pseudo-classes
:root

:empty
:first-child

:last-child

:nth-child()

:only-child

:first-of-type

:last-of-type

:nth-of-type()

:only-of-type
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
PSEUDO-CLASSES / STRUCTURAL
With this code only the empty divs are shown in gray.
Selects an element that has no children at all.
div:empty {background: gray}
Syntax element:empty {style properties}
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
HTML CSS
Browser
PSEUDO-CLASSES / STRUCTURAL
<body>
<article>
<h2>Item 1</h2>
<p>Item description.</p>
</article>
<article><!-- No item here --></article>
</body>
article {
background: green;
width: 100px;
height: 100px;
}
article:empty {
background: gray;
}
Web page title
index.html
Item 1
Item description.
READY TO USE CODE
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
Structural 

pseudo-classes
:root

:empty

:first-child
:last-child

:nth-child()

:only-child

:first-of-type

:last-of-type

:nth-of-type()

:only-of-type
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
PSEUDO-CLASSES / STRUCTURAL
With this code only the first li of a list is shown in green.
Selects an element that is first in a list of siblings.
li:first-child {color: green}
Syntax element:first-child {style properties}
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
HTML CSS
Browser
PSEUDO-CLASSES / STRUCTURAL
<body>
<ol>
<li>Usain Bolt - Gold</li>
<li>Yohan Blake - Silver</li>
<li>Justin Gatlin - Bronze</li>
</ol>
</body>
li:first-child { color: green; }
Web page title
index.html
1. Usain Bolt - Gold
2. Yohan Blake - Silver
3. Justin Gatlin - Bronze
READY TO USE CODE
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
Structural 

pseudo-classes
:root

:empty

:first-child

:last-child
:nth-child()

:only-child

:first-of-type

:last-of-type

:nth-of-type()

:only-of-type
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
PSEUDO-CLASSES / STRUCTURAL
With this code only the last li of a list is shown in green.
Selects an element that is last in a list of siblings.
li:last-child {color: green}
Syntax element:last-child {style properties}
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
HTML CSS
Browser
PSEUDO-CLASSES / STRUCTURAL
<body>
<ol>
<li>Usain Bolt - Gold</li>
<li>Yohan Blake - Silver</li>
<li>Justin Gatlin - Bronze</li>
<li>Miguel Sánchez - Retired ;)</li>
</ol>
</body>
li:last-child { color: green; }
Web page title
index.html
1. Usain Bolt - Gold
2. Yohan Blake - Silver
3. Justin Gatlin - Bronze
4. Miguel Sánchez - Retired ;)
READY TO USE CODE
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
Structural 

pseudo-classes
:root

:empty

:first-child

:last-child

:nth-child()
:only-child

:first-of-type

:last-of-type

:nth-of-type()

:only-of-type
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
PSEUDO-CLASSES / STRUCTURAL
With this code every odd li of a list is shown in green.
Selects an element that has an+b-1 siblings before it in the document tree and has a parent element.
li:nth-child(2n+1) {color: green}
Syntax element:nth-child(an + b) {style properties}
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
PSEUDO-CLASSES / STRUCTURAL
li:nth-child(4) { color: green; }
• Item 1

• Item 2

• Item 3

• Item 4

• Item 5

• Item 6

• Item 7

• Item 8
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
PSEUDO-CLASSES / STRUCTURAL
li:nth-child(2n+1) { color: green; }
• Item 1

• Item 2

• Item 3

• Item 4

• Item 5

• Item 6

• Item 7

• Item 8
First term
Difference
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
PSEUDO-CLASSES / STRUCTURAL
li:nth-child(2n+2) { color: green; }
• Item 1

• Item 2

• Item 3

• Item 4

• Item 5

• Item 6

• Item 7

• Item 8
First term
Difference
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
PSEUDO-CLASSES / STRUCTURAL
li:nth-child(odd) { color: green; }
• Item 1

• Item 2

• Item 3

• Item 4

• Item 5

• Item 6

• Item 7

• Item 8
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
PSEUDO-CLASSES / STRUCTURAL
li:nth-child(even) { color: green; }
• Item 1

• Item 2

• Item 3

• Item 4

• Item 5

• Item 6

• Item 7

• Item 8
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
PSEUDO-CLASSES / STRUCTURAL
li:nth-child(1n+3) { color: green; }
• Item 1

• Item 2

• Item 3

• Item 4

• Item 5

• Item 6

• Item 7

• Item 8
First term
Difference
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
PSEUDO-CLASSES / STRUCTURAL
li:nth-child(3n+3) { color: green; }
• Item 1

• Item 2

• Item 3

• Item 4

• Item 5

• Item 6

• Item 7

• Item 8
First term
Difference
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
Structural 

pseudo-classes
:root

:empty

:first-child

:last-child

:nth-child()

:only-child
:first-of-type

:last-of-type

:nth-of-type()

:only-of-type
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
PSEUDO-CLASSES / STRUCTURAL
With this code only an li without siblings is shown in green.
Selects an element that has no siblings.
li:only-child {color: green}
Syntax element:only-child {style properties}
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
HTML CSS
Browser
PSEUDO-CLASSES / STRUCTURAL
<body>
<h2>Search results: devices</h2>
<ul>
<li>Laptops</li>
<li>Smartphones</li>
</ul>
<h2>Search results: accessories</h2>
<ul>
<li>No results found</li>
</ul>
</body>
li:only-child { color: green; }
Web page title
index.html
Search results: devices
• Laptops
• Smartphones
Search results: accessories
• No results found
READY TO USE CODE
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
Structural 

pseudo-classes
:root

:empty

:first-child

:last-child

:nth-child()

:only-child

:first-of-type
:last-of-type

:nth-of-type()

:only-of-type
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
PSEUDO-CLASSES / STRUCTURAL
With this code only the first p in a group of children paragraphs is shown in green.
Selects an element that is the first sibling of its type.
p:first-of-type {color: green}
Syntax element:first-of-type {style properties}
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
HTML CSS
Browser
PSEUDO-CLASSES / STRUCTURAL
<body>
<main>
<h2>Featured product</h2>
<p>Product description.</p>
<h2>Second product</h2>
<p>Product description.</p>
</main>
</body>
p:first-of-type { color: green; }
Web page title
index.html
Featured product
Product description.
Second product
Product description.
READY TO USE CODE
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
Structural 

pseudo-classes
:root

:empty

:first-child

:last-child

:nth-child()

:only-child

:first-of-type

:last-of-type
:nth-of-type()

:only-of-type
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
PSEUDO-CLASSES / STRUCTURAL
With this code only the last p in a group of children paragraphs is shown in green.
Selects an element that is the last sibling of its type.
p:last-of-type {color: green}
Syntax element:first-of-type {style properties}
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
HTML CSS
Browser
PSEUDO-CLASSES / STRUCTURAL
<body>
<main>
<h2>First product</h2>
<p>Product description.</p>
<h2>Expiring product</h2>
<p>Last units available.</p>
</main>
</body>
p:last-of-type { color: green; }
Web page title
index.html
First product
Product description.
Expiring product
Last units available.
READY TO USE CODE
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
Structural 

pseudo-classes
:root

:empty

:first-child

:last-child

:nth-child()

:only-child

:first-of-type

:last-of-type

:nth-of-type()
:only-of-type
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
PSEUDO-CLASSES / STRUCTURAL
With this code only the odd paragraphs in a group of children paragraphs are shown in green.
Selects elements of a given type, based on their position among a group of siblings.
p:nth-of-type(odd) {color: green}
Syntax element:nth-of-type() {style properties}
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
HTML CSS
Browser
PSEUDO-CLASSES / STRUCTURAL
<body>
<main>
<h2>Product 1</h2>
<p>Product description.</p>
<h2>Product 2</h2>
<p>Product description.</p>
<h2>Product 3</h2>
<p>Product description.</p>
<h2>Product 4</h2>
<p>Product description.</p>
</main>
</body>
p:nth-of-type(odd) { color: green; }
Web page title
index.html
Product 1
Product description.
Product 2
Product description.
Product 3
Product description.
Product 4
Product description.
READY TO USE CODE
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
Structural 

pseudo-classes
:root

:empty

:first-child

:last-child

:nth-child()

:only-child

:first-of-type

:last-of-type

:nth-of-type()

:only-of-type
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
PSEUDO-CLASSES / STRUCTURAL
With this code only the paragraph with no other siblign paragraphs is shown in green.
Selects an element that has no siblings with the same expanded element name.
p:only-of-type {color: green}
Syntax element:only-of-type() {style properties}
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
HTML CSS
Browser
PSEUDO-CLASSES / STRUCTURAL
<body>
<article>
<h2>Product 1</h2>
<p>Product description.</p>
<p>Description continues here.</p>
</article>
<article>
<h2>Product 2</h2>
<p>Out of stock.</p>
</article>
</body>
p:only-of-type { color: green; }
Web page title
index.html
Product 1
Product description.
Description continues here.
Product 2
Out of stock.
READY TO USE CODE
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
TARGET &
LANG
UI ELEMENT
STATES
DYNAMIC
NEGATIONSTRUCTURAL
PSEUDO-CLASSES PSEUDO-CLASSES PSEUDO-CLASSES
PSEUDO-CLASSES PSEUDO-CLASSES
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
PSEUDO-CLASSES / NEGATION
With this code all the elements of a header are shown in green, excluding all h1 headers.
Selects elements that do not match a list of selectors.
header :not(h1) {color: green}
Syntax element:not(X) {style properties}
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
HTML CSS
Browser
PSEUDO-CLASSES / NEGATION
<body>
<header>
<h1>Company name</h1>
<h1>Tagline</h1>
<nav>Navigation goes here.</nav>
<div>User not logged in.</div>
</header>
</body>
header :not(h1) { color: green; }
Web page title
index.html
Company name
Tagline
Product description.
User not logged in.
READY TO USE CODE
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
HTML CSS
Browser
PSEUDO-CLASSES / NEGATION
<body>
<p class="mini">Paragraph goes here.</p>
<p>Paragraph goes here.</p>
<p class="mini">Paragraph goes here.</p>
</body>
.mini { color: black; }
p:not(.mini) { color: green; }
Web page title
index.html
Paragraph goes here.
Paragraph goes here.
Paragraph goes here.
READY TO USE CODE
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
TARGET &
LANG
UI ELEMENT
STATES
DYNAMIC
NEGATIONSTRUCTURAL
PSEUDO-CLASSES PSEUDO-CLASSES PSEUDO-CLASSES
PSEUDO-CLASSES PSEUDO-CLASSES
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
REFERENCE: W3C
SOURCE: Selectors Level 3 by W3C.
Learn front-end development at rocket speed
inarocket.com
by miguelsanchez.com
YOU CAN CONTINUE THIS COURSE FOR FREE ON
+ READY TO USE CODE
+ QUIZZES
+ FREE UPDATES
We respect your time

No more blah blah videos. Just straight to
the point slides with relevant information.
Ready to use code

Real code you can just copy and paste into
your real projects.
Step by step guides

Clear and concise steps to build real use
solutions. No missed points.
Learn front-end development at rocket speed
inarocket.com
IN A ROCKET
Learn front-end development at rocket speed
CSS CSS FUNDAMENTALS
Pseudo-class

More Related Content

What's hot (20)

PDF
Introduction to HTML and CSS
Mario Hernandez
 
PDF
HTML and CSS crash course!
Ana Cidre
 
ODP
Introduction to css & its attributes with syntax
priyadharshini murugan
 
PPT
jQuery
Mostafa Bayomi
 
PPTX
Web design - Working with Links and Images
Mustafa Kamel Mohammadi
 
PDF
Basic-CSS-tutorial
tutorialsruby
 
PPT
Html & Css presentation
joilrahat
 
PPT
cascading style sheet ppt
abhilashagupta
 
PPTX
HTML Fundamentals
BG Java EE Course
 
PPTX
Html
Nisa Soomro
 
PPTX
Css
Hemant Saini
 
PDF
Introduction to Javascript
Seble Nigussie
 
PPTX
html-css
Dhirendra Chauhan
 
PDF
CSS Dasar #5 : Text Styling
Sandhika Galih
 
PPTX
Basic HTML
Sayan De
 
PPTX
Css selectors
Parth Trivedi
 
PPT
CSS for Beginners
Amit Kumar Singh
 
Introduction to HTML and CSS
Mario Hernandez
 
HTML and CSS crash course!
Ana Cidre
 
Introduction to css & its attributes with syntax
priyadharshini murugan
 
Web design - Working with Links and Images
Mustafa Kamel Mohammadi
 
Basic-CSS-tutorial
tutorialsruby
 
Html & Css presentation
joilrahat
 
cascading style sheet ppt
abhilashagupta
 
HTML Fundamentals
BG Java EE Course
 
Introduction to Javascript
Seble Nigussie
 
CSS Dasar #5 : Text Styling
Sandhika Galih
 
Basic HTML
Sayan De
 
Css selectors
Parth Trivedi
 
CSS for Beginners
Amit Kumar Singh
 

Similar to 9- Learn CSS Fundamentals / Pseudo-classes (20)

PDF
12- Learn CSS Fundamentals / Mix & group
In a Rocket
 
PPTX
JAVAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
KimberlyCasem1
 
PDF
10- Learn CSS Fundamentals / Pseudo-elements
In a Rocket
 
PDF
11- Learn CSS Fundamentals / Combinators
In a Rocket
 
PDF
13- Learn CSS Fundamentals / Specificity
In a Rocket
 
PDF
Learn css3
Mostafa Bayomi
 
PDF
BYOWHC823
Thinkful
 
PPTX
CSS
Akila Iroshan
 
PPTX
Introduction to Html5, css, Javascript and Jquery
valuebound
 
PDF
15- Learn CSS Fundamentals / Color
In a Rocket
 
PPTX
Css pseudo-classes
Webtech Learning
 
PPT
Css class-02
Md Ali Hossain
 
PDF
Fccwc326
Shannon Gallagher
 
PDF
Intro to HTML and CSS - Class 2 Slides
Heather Rock
 
PDF
04 CSS #burningkeyboards
Denis Ristic
 
PPTX
css v1 guru
GuruPada Das
 
PDF
cascading style sheet for web developer.pdf
nawasyt700
 
PDF
Professional Css
Subramanyan Murali
 
PDF
HTML+CSS: how to get started
Dimitris Tsironis
 
PPTX
Lab#1 - Front End Development
Walid Ashraf
 
12- Learn CSS Fundamentals / Mix & group
In a Rocket
 
JAVAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
KimberlyCasem1
 
10- Learn CSS Fundamentals / Pseudo-elements
In a Rocket
 
11- Learn CSS Fundamentals / Combinators
In a Rocket
 
13- Learn CSS Fundamentals / Specificity
In a Rocket
 
Learn css3
Mostafa Bayomi
 
BYOWHC823
Thinkful
 
Introduction to Html5, css, Javascript and Jquery
valuebound
 
15- Learn CSS Fundamentals / Color
In a Rocket
 
Css pseudo-classes
Webtech Learning
 
Css class-02
Md Ali Hossain
 
Intro to HTML and CSS - Class 2 Slides
Heather Rock
 
04 CSS #burningkeyboards
Denis Ristic
 
css v1 guru
GuruPada Das
 
cascading style sheet for web developer.pdf
nawasyt700
 
Professional Css
Subramanyan Murali
 
HTML+CSS: how to get started
Dimitris Tsironis
 
Lab#1 - Front End Development
Walid Ashraf
 
Ad

More from In a Rocket (11)

PDF
3- Learn Flexbox & CSS Grid / Container & items
In a Rocket
 
PDF
2- Learn Flexbox & CSS Grid / Context
In a Rocket
 
PDF
1- Learn Flexbox & CSS Grid / Environment setup
In a Rocket
 
PDF
17- Learn CSS Fundamentals / Units
In a Rocket
 
PDF
16- Learn CSS Fundamentals / Background
In a Rocket
 
PDF
14- Learn CSS Fundamentals / Inheritance
In a Rocket
 
PDF
8- Learn CSS Fundamentals / Attribute selectors
In a Rocket
 
PDF
2- Learn HTML Fundamentals / Text Formatting
In a Rocket
 
PDF
1- Learn HTML Fundamentals / Start in 5 Minutes
In a Rocket
 
PDF
Learn SUIT: CSS Naming Convention
In a Rocket
 
PDF
Learn BEM: CSS Naming Convention
In a Rocket
 
3- Learn Flexbox & CSS Grid / Container & items
In a Rocket
 
2- Learn Flexbox & CSS Grid / Context
In a Rocket
 
1- Learn Flexbox & CSS Grid / Environment setup
In a Rocket
 
17- Learn CSS Fundamentals / Units
In a Rocket
 
16- Learn CSS Fundamentals / Background
In a Rocket
 
14- Learn CSS Fundamentals / Inheritance
In a Rocket
 
8- Learn CSS Fundamentals / Attribute selectors
In a Rocket
 
2- Learn HTML Fundamentals / Text Formatting
In a Rocket
 
1- Learn HTML Fundamentals / Start in 5 Minutes
In a Rocket
 
Learn SUIT: CSS Naming Convention
In a Rocket
 
Learn BEM: CSS Naming Convention
In a Rocket
 
Ad

Recently uploaded (17)

PPTX
Class_4_Limbgvchgchgchgchgchgcjhgchgcnked_Lists.pptx
test123n
 
PPTX
Ransomware attack and its effects on cyber crimes
ShilpaShreeD
 
PDF
Materi tentang From Digital Economy to Fintech.pdf
Abdul Hakim
 
PDF
ContextForge MCP Gateway - the missing proxy for AI Agents and Tools
Mihai Criveti
 
PDF
The Convergence of Threat Behaviors Across Intrusions
Joe Slowik
 
PPTX
CHAPTER 1 - PART 3 FOR GRADE 11 STUDENTS
FSBTLEDNathanVince
 
PPTX
Lesson 1.1 Career-Opportunities-in-Ict.pptx
lizelgumadlas1
 
PDF
web application development company in bangalore.pdf
https://dkpractice.co.in/seo.html tech
 
PPTX
Meloniusk_Communication_Template_best.pptx
howesix147
 
PPTX
Q1 English3 Week5 PPT-MATATAG@edumaymay.pptx
JenniferCawaling1
 
PDF
AI security AI security AI security AI security
elite44
 
PPTX
原版一样(ANU毕业证书)澳洲澳大利亚国立大学毕业证在线购买
Taqyea
 
PDF
Strategic Plan New and Completed Templeted
alvi932317
 
PDF
Clive Dickens RedTech Public Copy - Collaborate or Die
Clive Dickens
 
PDF
Beginning-Laravel-Build-Websites-with-Laravel-5.8-by-Sanjib-Sinha-z-lib.org.pdf
TagumLibuganonRiverB
 
PDF
Empowering Local Language Email with IDN & EAI – Powered by XgenPlus
XgenPlus Technologies
 
PPTX
My Mother At 66! (2).pptx00000000000000000000000000000
vedapattisiddharth
 
Class_4_Limbgvchgchgchgchgchgcjhgchgcnked_Lists.pptx
test123n
 
Ransomware attack and its effects on cyber crimes
ShilpaShreeD
 
Materi tentang From Digital Economy to Fintech.pdf
Abdul Hakim
 
ContextForge MCP Gateway - the missing proxy for AI Agents and Tools
Mihai Criveti
 
The Convergence of Threat Behaviors Across Intrusions
Joe Slowik
 
CHAPTER 1 - PART 3 FOR GRADE 11 STUDENTS
FSBTLEDNathanVince
 
Lesson 1.1 Career-Opportunities-in-Ict.pptx
lizelgumadlas1
 
web application development company in bangalore.pdf
https://dkpractice.co.in/seo.html tech
 
Meloniusk_Communication_Template_best.pptx
howesix147
 
Q1 English3 Week5 PPT-MATATAG@edumaymay.pptx
JenniferCawaling1
 
AI security AI security AI security AI security
elite44
 
原版一样(ANU毕业证书)澳洲澳大利亚国立大学毕业证在线购买
Taqyea
 
Strategic Plan New and Completed Templeted
alvi932317
 
Clive Dickens RedTech Public Copy - Collaborate or Die
Clive Dickens
 
Beginning-Laravel-Build-Websites-with-Laravel-5.8-by-Sanjib-Sinha-z-lib.org.pdf
TagumLibuganonRiverB
 
Empowering Local Language Email with IDN & EAI – Powered by XgenPlus
XgenPlus Technologies
 
My Mother At 66! (2).pptx00000000000000000000000000000
vedapattisiddharth
 

9- Learn CSS Fundamentals / Pseudo-classes

  • 1. IN A ROCKET Learn front-end development at rocket speed CSS CSS FUNDAMENTALS Pseudo-class
  • 2. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com PSEUDO-CLASSES With this code all a elements that have not yet been visited are shown in green. A pseudo-class selects an element with a special state specified by a keyword. a:link {color: green} Syntax selector:pseudo-class {style properties}
  • 3. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com TARGET & LANG UI ELEMENT STATES DYNAMIC NEGATIONSTRUCTURAL PSEUDO-CLASSES PSEUDO-CLASSES PSEUDO-CLASSES PSEUDO-CLASSES PSEUDO-CLASSES
  • 4. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com Dynamic 
 pseudo-classes :link :visited :hover :active :focus
  • 5. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com PSEUDO-CLASSES / DYNAMIC / LINK STATES Contact a:link 
 Represents links that have 
 not yet been visited. Contact a:visited 
 Styles for links that have been visited
 (exists in the browser's history). Contact a:active 
 Triggered when the user clicks the link or 
 selects it with the keyboard's tab key. CLICKED Contact a:hover 
 Generally triggered when the user hovers over 
 an element with the cursor (mouse pointer).
  • 6. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com Dynamic 
 pseudo-classes :link :visited :hover :active :focus How to remember them? 😍 LOVE 😤 HATE
  • 7. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com PSEUDO-CLASSES / DYNAMIC With this code all not visited links are shown in green. Selects all links that have not yet been visited. a:link {color: green} Syntax selector:link {style properties}
  • 8. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com HTML CSS Browser PSEUDO-CLASSES / DYNAMIC <body> <a href="#">Not visited.</a> <a href="#">Visited.</a> <a href="#">Hover.</a> <a href="#">Active.</a> <input type="text" name="zip" id="zip"> </body> a:link { color: blue; } a:visited { color: purple; } a:hover { color: green; } a:active { color: red; } input:focus { color: orange; } Web page title index.html Not visited. Pressed Visited. Hover. Active. Writing here... READY TO USE CODE
  • 9. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com TARGET & LANG UI ELEMENT STATES DYNAMIC NEGATIONSTRUCTURAL PSEUDO-CLASSES PSEUDO-CLASSES PSEUDO-CLASSES PSEUDO-CLASSES PSEUDO-CLASSES
  • 10. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com PSEUDO-CLASSES / TARGET & LANG With this code the terms fragment identifier is shown in green. Selects a fragment identifier that has a location within a resource. h2:terms {color: green} Syntax selector:target {style properties}
  • 11. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com HTML CSS Browser PSEUDO-CLASSES / TARGET & LANG <body> <a href="#about">About.</a> <a href="#terms">Terms.</a> <h2 id="about">About our company</h2> <h2 id="terms">Terms of use</h2> </body> h2:target { color: green; } Web page title index.html - About. - Terms. About our company Terms of use READY TO USE CODE
  • 12. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com PSEUDO-CLASSES / TARGET & LANG With this code the paragraphs in English (en) are shown in green. Selects elements based on the language they are determined to be in. p:lang(en) {color: green} Syntax selector:lang(lg) {style properties}
  • 13. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com HTML CSS Browser PSEUDO-CLASSES / TARGET & LANG <body> <p lang="en"><q>To be, or not to be: that is the question.</q></p> <p lang="es"><q>En un lugar de la Mancha, de cuyo nombre no quiero acordarme...</q></p> </body> p:lang(en) > q { quotes: '201C' '201D'; } p:lang(es) > q { quotes: '«' '»'; } Web page title index.html “To be, or not to be: that is the question.” «En un lugar de la Mancha, de cuyo nombre no quiero acordarme...» READY TO USE CODE
  • 14. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com TARGET & LANG UI ELEMENT STATES DYNAMIC NEGATIONSTRUCTURAL PSEUDO-CLASSES PSEUDO-CLASSES PSEUDO-CLASSES PSEUDO-CLASSES PSEUDO-CLASSES
  • 15. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com PSEUDO-CLASSES / UI ELEMENT STATES With this code only the enabled inputs are shown in green. Selects any enabled element (it can be selected, clicked on, typed into, etc.). input:enabled {color: green} Syntax selector:enabled {style properties}
  • 16. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com PSEUDO-CLASSES / UI ELEMENT STATES With this code only the disabled inputs are shown in green. Selects any disabled element. input:disabled {color: green} Syntax selector:enabled {style properties}
  • 17. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com HTML CSS Browser PSEUDO-CLASSES / UI ELEMENT STATES <body> <form> <label for="name">Name:</label> <input type="text" id="name"> <label for="city">City:</label> <input type="text" id="city" value="NYC" disabled="disabled"> <input type="button" value="Submit"> </form> </body> input:enabled { color: green; } input:disabled { color: gray; } Web page title index.html Name: City: John Doe NYC READY TO USE CODE
  • 18. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com PSEUDO-CLASSES / UI ELEMENT STATES With this code only the checked inputs are shown in green. Selects any radio, checkbox or option that is checked or toggled to an on state. input:checked {color: green} Syntax selector:checked {style properties}
  • 19. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com HTML CSS Browser PSEUDO-CLASSES / UI ELEMENT STATES <body> <form> <input type="radio" name="pay" id="cash"> <label for="cash">Cash</label> <input type="radio" name="pay" id="card"> <label for="card">Card</label> <input type="checkbox" name="nwslt" id="nwslt"> <label for="nwslt">Subscribe me!</label> </form> </body> input[type=radio]:checked + label { color: green; } input[type=checkbox]:checked + label { color: blue; } Web page title index.html Cash Card Subscribe me! READY TO USE CODE
  • 20. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com TARGET & LANG UI ELEMENT STATES DYNAMIC NEGATIONSTRUCTURAL PSEUDO-CLASSES PSEUDO-CLASSES PSEUDO-CLASSES PSEUDO-CLASSES PSEUDO-CLASSES
  • 21. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com Structural 
 pseudo-classes :root :empty :first-child :last-child :nth-child() :only-child :first-of-type :last-of-type :nth-of-type() :only-of-type
  • 22. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com PSEUDO-CLASSES / STRUCTURAL Selects an element that is the root of the document (in HTML, this is always the HTML element). :root {color: green} Syntax :root {style properties}
  • 23. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com HTML CSS Browser PSEUDO-CLASSES / STRUCTURAL <body> <h2>Lorem ipsum dolor</h2> <p>Nostrum similique veniam commodi sed esse earum voluptatum corrupti at quam voluptates?</p> <ul> <li>Esse</li> <li>Earum</li> </ul> </body> :root { color: green; } Web page title index.html Lorem ipsum dolor Nostrum similique veniam commodi sed esse earum voluptatum corrupti at quam voluptates? • Esse • Earum READY TO USE CODE
  • 24. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com HTML CSS Browser PSEUDO-CLASSES / STRUCTURAL <body> <h2>Lorem ipsum dolor</h2> <p>Nostrum similique veniam commodi sed esse earum voluptatum corrupti at quam voluptates? </p> </body> :root { --color-primary: blue; --color-secondary: gray; } p { background: var(--color-secondary); color: var(--color-primary); } Web page title index.html Lorem ipsum dolor Nostrum similique veniam commodi sed esse earum voluptatum corrupti at quam voluptates? READY TO USE CODE
  • 25. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com Structural 
 pseudo-classes :root :empty :first-child :last-child :nth-child() :only-child :first-of-type :last-of-type :nth-of-type() :only-of-type
  • 26. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com PSEUDO-CLASSES / STRUCTURAL With this code only the empty divs are shown in gray. Selects an element that has no children at all. div:empty {background: gray} Syntax element:empty {style properties}
  • 27. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com HTML CSS Browser PSEUDO-CLASSES / STRUCTURAL <body> <article> <h2>Item 1</h2> <p>Item description.</p> </article> <article><!-- No item here --></article> </body> article { background: green; width: 100px; height: 100px; } article:empty { background: gray; } Web page title index.html Item 1 Item description. READY TO USE CODE
  • 28. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com Structural 
 pseudo-classes :root :empty :first-child :last-child :nth-child() :only-child :first-of-type :last-of-type :nth-of-type() :only-of-type
  • 29. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com PSEUDO-CLASSES / STRUCTURAL With this code only the first li of a list is shown in green. Selects an element that is first in a list of siblings. li:first-child {color: green} Syntax element:first-child {style properties}
  • 30. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com HTML CSS Browser PSEUDO-CLASSES / STRUCTURAL <body> <ol> <li>Usain Bolt - Gold</li> <li>Yohan Blake - Silver</li> <li>Justin Gatlin - Bronze</li> </ol> </body> li:first-child { color: green; } Web page title index.html 1. Usain Bolt - Gold 2. Yohan Blake - Silver 3. Justin Gatlin - Bronze READY TO USE CODE
  • 31. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com Structural 
 pseudo-classes :root :empty :first-child :last-child :nth-child() :only-child :first-of-type :last-of-type :nth-of-type() :only-of-type
  • 32. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com PSEUDO-CLASSES / STRUCTURAL With this code only the last li of a list is shown in green. Selects an element that is last in a list of siblings. li:last-child {color: green} Syntax element:last-child {style properties}
  • 33. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com HTML CSS Browser PSEUDO-CLASSES / STRUCTURAL <body> <ol> <li>Usain Bolt - Gold</li> <li>Yohan Blake - Silver</li> <li>Justin Gatlin - Bronze</li> <li>Miguel Sánchez - Retired ;)</li> </ol> </body> li:last-child { color: green; } Web page title index.html 1. Usain Bolt - Gold 2. Yohan Blake - Silver 3. Justin Gatlin - Bronze 4. Miguel Sánchez - Retired ;) READY TO USE CODE
  • 34. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com Structural 
 pseudo-classes :root :empty :first-child :last-child :nth-child() :only-child :first-of-type :last-of-type :nth-of-type() :only-of-type
  • 35. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com PSEUDO-CLASSES / STRUCTURAL With this code every odd li of a list is shown in green. Selects an element that has an+b-1 siblings before it in the document tree and has a parent element. li:nth-child(2n+1) {color: green} Syntax element:nth-child(an + b) {style properties}
  • 36. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com PSEUDO-CLASSES / STRUCTURAL li:nth-child(4) { color: green; } • Item 1 • Item 2 • Item 3 • Item 4 • Item 5 • Item 6 • Item 7 • Item 8
  • 37. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com PSEUDO-CLASSES / STRUCTURAL li:nth-child(2n+1) { color: green; } • Item 1 • Item 2 • Item 3 • Item 4 • Item 5 • Item 6 • Item 7 • Item 8 First term Difference
  • 38. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com PSEUDO-CLASSES / STRUCTURAL li:nth-child(2n+2) { color: green; } • Item 1 • Item 2 • Item 3 • Item 4 • Item 5 • Item 6 • Item 7 • Item 8 First term Difference
  • 39. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com PSEUDO-CLASSES / STRUCTURAL li:nth-child(odd) { color: green; } • Item 1 • Item 2 • Item 3 • Item 4 • Item 5 • Item 6 • Item 7 • Item 8
  • 40. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com PSEUDO-CLASSES / STRUCTURAL li:nth-child(even) { color: green; } • Item 1 • Item 2 • Item 3 • Item 4 • Item 5 • Item 6 • Item 7 • Item 8
  • 41. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com PSEUDO-CLASSES / STRUCTURAL li:nth-child(1n+3) { color: green; } • Item 1 • Item 2 • Item 3 • Item 4 • Item 5 • Item 6 • Item 7 • Item 8 First term Difference
  • 42. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com PSEUDO-CLASSES / STRUCTURAL li:nth-child(3n+3) { color: green; } • Item 1 • Item 2 • Item 3 • Item 4 • Item 5 • Item 6 • Item 7 • Item 8 First term Difference
  • 43. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com Structural 
 pseudo-classes :root :empty :first-child :last-child :nth-child() :only-child :first-of-type :last-of-type :nth-of-type() :only-of-type
  • 44. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com PSEUDO-CLASSES / STRUCTURAL With this code only an li without siblings is shown in green. Selects an element that has no siblings. li:only-child {color: green} Syntax element:only-child {style properties}
  • 45. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com HTML CSS Browser PSEUDO-CLASSES / STRUCTURAL <body> <h2>Search results: devices</h2> <ul> <li>Laptops</li> <li>Smartphones</li> </ul> <h2>Search results: accessories</h2> <ul> <li>No results found</li> </ul> </body> li:only-child { color: green; } Web page title index.html Search results: devices • Laptops • Smartphones Search results: accessories • No results found READY TO USE CODE
  • 46. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com Structural 
 pseudo-classes :root :empty :first-child :last-child :nth-child() :only-child :first-of-type :last-of-type :nth-of-type() :only-of-type
  • 47. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com PSEUDO-CLASSES / STRUCTURAL With this code only the first p in a group of children paragraphs is shown in green. Selects an element that is the first sibling of its type. p:first-of-type {color: green} Syntax element:first-of-type {style properties}
  • 48. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com HTML CSS Browser PSEUDO-CLASSES / STRUCTURAL <body> <main> <h2>Featured product</h2> <p>Product description.</p> <h2>Second product</h2> <p>Product description.</p> </main> </body> p:first-of-type { color: green; } Web page title index.html Featured product Product description. Second product Product description. READY TO USE CODE
  • 49. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com Structural 
 pseudo-classes :root :empty :first-child :last-child :nth-child() :only-child :first-of-type :last-of-type :nth-of-type() :only-of-type
  • 50. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com PSEUDO-CLASSES / STRUCTURAL With this code only the last p in a group of children paragraphs is shown in green. Selects an element that is the last sibling of its type. p:last-of-type {color: green} Syntax element:first-of-type {style properties}
  • 51. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com HTML CSS Browser PSEUDO-CLASSES / STRUCTURAL <body> <main> <h2>First product</h2> <p>Product description.</p> <h2>Expiring product</h2> <p>Last units available.</p> </main> </body> p:last-of-type { color: green; } Web page title index.html First product Product description. Expiring product Last units available. READY TO USE CODE
  • 52. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com Structural 
 pseudo-classes :root :empty :first-child :last-child :nth-child() :only-child :first-of-type :last-of-type :nth-of-type() :only-of-type
  • 53. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com PSEUDO-CLASSES / STRUCTURAL With this code only the odd paragraphs in a group of children paragraphs are shown in green. Selects elements of a given type, based on their position among a group of siblings. p:nth-of-type(odd) {color: green} Syntax element:nth-of-type() {style properties}
  • 54. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com HTML CSS Browser PSEUDO-CLASSES / STRUCTURAL <body> <main> <h2>Product 1</h2> <p>Product description.</p> <h2>Product 2</h2> <p>Product description.</p> <h2>Product 3</h2> <p>Product description.</p> <h2>Product 4</h2> <p>Product description.</p> </main> </body> p:nth-of-type(odd) { color: green; } Web page title index.html Product 1 Product description. Product 2 Product description. Product 3 Product description. Product 4 Product description. READY TO USE CODE
  • 55. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com Structural 
 pseudo-classes :root :empty :first-child :last-child :nth-child() :only-child :first-of-type :last-of-type :nth-of-type() :only-of-type
  • 56. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com PSEUDO-CLASSES / STRUCTURAL With this code only the paragraph with no other siblign paragraphs is shown in green. Selects an element that has no siblings with the same expanded element name. p:only-of-type {color: green} Syntax element:only-of-type() {style properties}
  • 57. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com HTML CSS Browser PSEUDO-CLASSES / STRUCTURAL <body> <article> <h2>Product 1</h2> <p>Product description.</p> <p>Description continues here.</p> </article> <article> <h2>Product 2</h2> <p>Out of stock.</p> </article> </body> p:only-of-type { color: green; } Web page title index.html Product 1 Product description. Description continues here. Product 2 Out of stock. READY TO USE CODE
  • 58. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com TARGET & LANG UI ELEMENT STATES DYNAMIC NEGATIONSTRUCTURAL PSEUDO-CLASSES PSEUDO-CLASSES PSEUDO-CLASSES PSEUDO-CLASSES PSEUDO-CLASSES
  • 59. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com PSEUDO-CLASSES / NEGATION With this code all the elements of a header are shown in green, excluding all h1 headers. Selects elements that do not match a list of selectors. header :not(h1) {color: green} Syntax element:not(X) {style properties}
  • 60. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com HTML CSS Browser PSEUDO-CLASSES / NEGATION <body> <header> <h1>Company name</h1> <h1>Tagline</h1> <nav>Navigation goes here.</nav> <div>User not logged in.</div> </header> </body> header :not(h1) { color: green; } Web page title index.html Company name Tagline Product description. User not logged in. READY TO USE CODE
  • 61. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com HTML CSS Browser PSEUDO-CLASSES / NEGATION <body> <p class="mini">Paragraph goes here.</p> <p>Paragraph goes here.</p> <p class="mini">Paragraph goes here.</p> </body> .mini { color: black; } p:not(.mini) { color: green; } Web page title index.html Paragraph goes here. Paragraph goes here. Paragraph goes here. READY TO USE CODE
  • 62. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com TARGET & LANG UI ELEMENT STATES DYNAMIC NEGATIONSTRUCTURAL PSEUDO-CLASSES PSEUDO-CLASSES PSEUDO-CLASSES PSEUDO-CLASSES PSEUDO-CLASSES
  • 63. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com REFERENCE: W3C SOURCE: Selectors Level 3 by W3C.
  • 64. Learn front-end development at rocket speed inarocket.com by miguelsanchez.com YOU CAN CONTINUE THIS COURSE FOR FREE ON + READY TO USE CODE + QUIZZES + FREE UPDATES
  • 65. We respect your time
 No more blah blah videos. Just straight to the point slides with relevant information. Ready to use code
 Real code you can just copy and paste into your real projects. Step by step guides
 Clear and concise steps to build real use solutions. No missed points. Learn front-end development at rocket speed inarocket.com
  • 66. IN A ROCKET Learn front-end development at rocket speed CSS CSS FUNDAMENTALS Pseudo-class