SlideShare a Scribd company logo
Submit Search
Upload
Mastering CSS3 Selectors
Report
Share
Rachel Andrew
Writer, speaker, co-founder of Perch CMS. Google Developer Expert for Web Technologies at A List Apart
Follow
•
11 likes
•
1,998 views
1
of
99
Mastering CSS3 Selectors
•
11 likes
•
1,998 views
Report
Share
Download Now
Download to read offline
Technology
Presentation for Think Vitamin Online CSS3 Conference.
Read more
Rachel Andrew
Writer, speaker, co-founder of Perch CMS. Google Developer Expert for Web Technologies at A List Apart
Follow
Recommended
Refactoring by
Refactoring
Caike Souza
1.4K views
•
113 slides
Managing technical communicators in an XML environment by
Managing technical communicators in an XML environment
Scriptorium Publishing
478 views
•
21 slides
Empa Edtec Talk April 2010 by
Empa Edtec Talk April 2010
andersand
470 views
•
100 slides
开放式类库的构建 by
开放式类库的构建
lifesinger
1.2K views
•
63 slides
让开发也懂前端 by
让开发也懂前端
lifesinger
4.2K views
•
121 slides
CrossMark Sneak Peek 2010 CrossRef Workshops by
CrossMark Sneak Peek 2010 CrossRef Workshops
Crossref
636 views
•
86 slides
More Related Content
Viewers also liked
HTML5 Semantics by
HTML5 Semantics
Shay Howe
385 views
•
63 slides
Smacking Git Around Advanced Git Tricks by
Smacking Git Around Advanced Git Tricks
railsconf
2.7K views
•
415 slides
Quality Development with HTML5 by
Quality Development with HTML5
Shay Howe
20K views
•
72 slides
Git in a nutshell by
Git in a nutshell
Pranesh Vittal
3.4K views
•
22 slides
The git by
The git
Leonardo YongUk Kim
4.5K views
•
83 slides
Quality Development with CSS3 by
Quality Development with CSS3
Shay Howe
12.1K views
•
69 slides
Viewers also liked
(20)
HTML5 Semantics by Shay Howe
HTML5 Semantics
Shay Howe
•
385 views
Smacking Git Around Advanced Git Tricks by railsconf
Smacking Git Around Advanced Git Tricks
railsconf
•
2.7K views
Quality Development with HTML5 by Shay Howe
Quality Development with HTML5
Shay Howe
•
20K views
Git in a nutshell by Pranesh Vittal
Git in a nutshell
Pranesh Vittal
•
3.4K views
The git by Leonardo YongUk Kim
The git
Leonardo YongUk Kim
•
4.5K views
Quality Development with CSS3 by Shay Howe
Quality Development with CSS3
Shay Howe
•
12.1K views
CSS: selectors and the box model by Idan Gazit
CSS: selectors and the box model
Idan Gazit
•
3K views
Yes, Designer, You CAN Be a Product Leader by Shay Howe
Yes, Designer, You CAN Be a Product Leader
Shay Howe
•
340 views
An Intro to HTML & CSS by Shay Howe
An Intro to HTML & CSS
Shay Howe
•
435 views
CSS Selectors by Rachel Andrew
CSS Selectors
Rachel Andrew
•
4K views
Git in a nutshell by Nelson Tai
Git in a nutshell
Nelson Tai
•
10K views
Intro To Git by kyleburton
Intro To Git
kyleburton
•
4.6K views
Git and GitHub by James Gray
Git and GitHub
James Gray
•
11.3K views
Fundamental CSS3 by Achmad Solichin
Fundamental CSS3
Achmad Solichin
•
15.2K views
Advanced Git by segv
Advanced Git
segv
•
19.3K views
Git Tutorial 教學 by Wen-Tien Chang
Git Tutorial 教學
Wen-Tien Chang
•
57.9K views
Getting Git Right by Sven Peters
Getting Git Right
Sven Peters
•
152.2K views
Intro to CSS3 by Denise Jacobs
Intro to CSS3
Denise Jacobs
•
57.2K views
Introduction to Git/Github - A beginner's guide by Rohit Arora
Introduction to Git/Github - A beginner's guide
Rohit Arora
•
53.1K views
Getting Git by Scott Chacon
Getting Git
Scott Chacon
•
24.1K views
Similar to Mastering CSS3 Selectors
IE9 для разработчиков by
IE9 для разработчиков
Yuriy Artyukh
749 views
•
56 slides
Cutting Edge CSS3 @ WebExpo Tour 2010 by
Cutting Edge CSS3 @ WebExpo Tour 2010
Zi Bin Cheah
973 views
•
56 slides
The Limited Red Society by
The Limited Red Society
Naresh Jain
6.2K views
•
61 slides
Hardcore Extending Rails 3 - From RailsConf '10 by
Hardcore Extending Rails 3 - From RailsConf '10
Rick Martínez
855 views
•
61 slides
Poisoning Rubinius: The _why and How by
Poisoning Rubinius: The _why and How
Brian Ford
2.1K views
•
83 slides
使用 PandaForm.com 製作及管理網上表格 by
使用 PandaForm.com 製作及管理網上表格
Daniel Cheng
368 views
•
16 slides
Similar to Mastering CSS3 Selectors
(8)
IE9 для разработчиков by Yuriy Artyukh
IE9 для разработчиков
Yuriy Artyukh
•
749 views
Cutting Edge CSS3 @ WebExpo Tour 2010 by Zi Bin Cheah
Cutting Edge CSS3 @ WebExpo Tour 2010
Zi Bin Cheah
•
973 views
The Limited Red Society by Naresh Jain
The Limited Red Society
Naresh Jain
•
6.2K views
Hardcore Extending Rails 3 - From RailsConf '10 by Rick Martínez
Hardcore Extending Rails 3 - From RailsConf '10
Rick Martínez
•
855 views
Poisoning Rubinius: The _why and How by Brian Ford
Poisoning Rubinius: The _why and How
Brian Ford
•
2.1K views
使用 PandaForm.com 製作及管理網上表格 by Daniel Cheng
使用 PandaForm.com 製作及管理網上表格
Daniel Cheng
•
368 views
Object garphs swapping by Mariano Martínez Peck
Object garphs swapping
Mariano Martínez Peck
•
422 views
Snowflake in music by Erik Duval
Snowflake in music
Erik Duval
•
415 views
More from Rachel Andrew
All Day Hey! Unlocking The Power of CSS Grid Layout by
All Day Hey! Unlocking The Power of CSS Grid Layout
Rachel Andrew
2.2K views
•
113 slides
SmashingConf SF: Unlocking the Power of CSS Grid Layout by
SmashingConf SF: Unlocking the Power of CSS Grid Layout
Rachel Andrew
2.3K views
•
113 slides
Unlocking the Power of CSS Grid Layout by
Unlocking the Power of CSS Grid Layout
Rachel Andrew
2K views
•
113 slides
The Creative New World of CSS by
The Creative New World of CSS
Rachel Andrew
2K views
•
144 slides
Into the Weeds of CSS Layout by
Into the Weeds of CSS Layout
Rachel Andrew
1.5K views
•
93 slides
Solving Layout Problems with CSS Grid & Friends - DevFest17 by
Solving Layout Problems with CSS Grid & Friends - DevFest17
Rachel Andrew
2.1K views
•
96 slides
More from Rachel Andrew
(20)
All Day Hey! Unlocking The Power of CSS Grid Layout by Rachel Andrew
All Day Hey! Unlocking The Power of CSS Grid Layout
Rachel Andrew
•
2.2K views
SmashingConf SF: Unlocking the Power of CSS Grid Layout by Rachel Andrew
SmashingConf SF: Unlocking the Power of CSS Grid Layout
Rachel Andrew
•
2.3K views
Unlocking the Power of CSS Grid Layout by Rachel Andrew
Unlocking the Power of CSS Grid Layout
Rachel Andrew
•
2K views
The Creative New World of CSS by Rachel Andrew
The Creative New World of CSS
Rachel Andrew
•
2K views
Into the Weeds of CSS Layout by Rachel Andrew
Into the Weeds of CSS Layout
Rachel Andrew
•
1.5K views
Solving Layout Problems with CSS Grid & Friends - DevFest17 by Rachel Andrew
Solving Layout Problems with CSS Grid & Friends - DevFest17
Rachel Andrew
•
2.1K views
Graduating to Grid by Rachel Andrew
Graduating to Grid
Rachel Andrew
•
1.6K views
View Source London: Solving Layout Problems with CSS Grid & Friends by Rachel Andrew
View Source London: Solving Layout Problems with CSS Grid & Friends
Rachel Andrew
•
1K views
DevFest Nantes - Start Using CSS Grid Layout today by Rachel Andrew
DevFest Nantes - Start Using CSS Grid Layout today
Rachel Andrew
•
1.1K views
Start Using CSS Grid Layout Today - RuhrJS by Rachel Andrew
Start Using CSS Grid Layout Today - RuhrJS
Rachel Andrew
•
990 views
404.ie: Solving Layout Problems with CSS Grid & Friends by Rachel Andrew
404.ie: Solving Layout Problems with CSS Grid & Friends
Rachel Andrew
•
909 views
Solving Layout Problems with CSS Grid & Friends - WEBU17 by Rachel Andrew
Solving Layout Problems with CSS Grid & Friends - WEBU17
Rachel Andrew
•
902 views
Laying out the future with grid & flexbox - Smashing Conf Freiburg by Rachel Andrew
Laying out the future with grid & flexbox - Smashing Conf Freiburg
Rachel Andrew
•
2.4K views
Solving Layout Problems with CSS Grid & Friends - NordicJS by Rachel Andrew
Solving Layout Problems with CSS Grid & Friends - NordicJS
Rachel Andrew
•
2.7K views
Google Developers Experts Summit 2017 - CSS Layout by Rachel Andrew
Google Developers Experts Summit 2017 - CSS Layout
Rachel Andrew
•
1.4K views
Web Summer Camp Keynote by Rachel Andrew
Web Summer Camp Keynote
Rachel Andrew
•
1.9K views
New CSS Layout Meets the Real World by Rachel Andrew
New CSS Layout Meets the Real World
Rachel Andrew
•
864 views
An Event Apart DC - New CSS Layout meets the Real World by Rachel Andrew
An Event Apart DC - New CSS Layout meets the Real World
Rachel Andrew
•
408 views
Perch, Patterns and Old Browsers by Rachel Andrew
Perch, Patterns and Old Browsers
Rachel Andrew
•
1.8K views
Evergreen websites for Evergreen browsers by Rachel Andrew
Evergreen websites for Evergreen browsers
Rachel Andrew
•
1.5K views
Recently uploaded
Melek BEN MAHMOUD.pdf by
Melek BEN MAHMOUD.pdf
MelekBenMahmoud
14 views
•
1 slide
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N... by
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
James Anderson
85 views
•
32 slides
The Research Portal of Catalonia: Growing more (information) & more (services) by
The Research Portal of Catalonia: Growing more (information) & more (services)
CSUC - Consorci de Serveis Universitaris de Catalunya
80 views
•
25 slides
Five Things You SHOULD Know About Postman by
Five Things You SHOULD Know About Postman
Postman
33 views
•
43 slides
Mini-Track: Challenges to Network Automation Adoption by
Mini-Track: Challenges to Network Automation Adoption
Network Automation Forum
12 views
•
27 slides
Network Source of Truth and Infrastructure as Code revisited by
Network Source of Truth and Infrastructure as Code revisited
Network Automation Forum
26 views
•
45 slides
Recently uploaded
(20)
Melek BEN MAHMOUD.pdf by MelekBenMahmoud
Melek BEN MAHMOUD.pdf
MelekBenMahmoud
•
14 views
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N... by James Anderson
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
James Anderson
•
85 views
The Research Portal of Catalonia: Growing more (information) & more (services) by CSUC - Consorci de Serveis Universitaris de Catalunya
The Research Portal of Catalonia: Growing more (information) & more (services)
CSUC - Consorci de Serveis Universitaris de Catalunya
•
80 views
Five Things You SHOULD Know About Postman by Postman
Five Things You SHOULD Know About Postman
Postman
•
33 views
Mini-Track: Challenges to Network Automation Adoption by Network Automation Forum
Mini-Track: Challenges to Network Automation Adoption
Network Automation Forum
•
12 views
Network Source of Truth and Infrastructure as Code revisited by Network Automation Forum
Network Source of Truth and Infrastructure as Code revisited
Network Automation Forum
•
26 views
Unit 1_Lecture 2_Physical Design of IoT.pdf by StephenTec
Unit 1_Lecture 2_Physical Design of IoT.pdf
StephenTec
•
12 views
Empathic Computing: Delivering the Potential of the Metaverse by Mark Billinghurst
Empathic Computing: Delivering the Potential of the Metaverse
Mark Billinghurst
•
478 views
Evolving the Network Automation Journey from Python to Platforms by Network Automation Forum
Evolving the Network Automation Journey from Python to Platforms
Network Automation Forum
•
13 views
METHOD AND SYSTEM FOR PREDICTING OPTIMAL LOAD FOR WHICH THE YIELD IS MAXIMUM ... by Prity Khastgir IPR Strategic India Patent Attorney Amplify Innovation
METHOD AND SYSTEM FOR PREDICTING OPTIMAL LOAD FOR WHICH THE YIELD IS MAXIMUM ...
Prity Khastgir IPR Strategic India Patent Attorney Amplify Innovation
•
29 views
Special_edition_innovator_2023.pdf by WillDavies22
Special_edition_innovator_2023.pdf
WillDavies22
•
17 views
Zero to Automated in Under a Year by Network Automation Forum
Zero to Automated in Under a Year
Network Automation Forum
•
15 views
Vertical User Stories by Moisés Armani Ramírez
Vertical User Stories
Moisés Armani Ramírez
•
14 views
Design Driven Network Assurance by Network Automation Forum
Design Driven Network Assurance
Network Automation Forum
•
15 views
PRODUCT LISTING.pptx by angelicacueva6
PRODUCT LISTING.pptx
angelicacueva6
•
14 views
Attacking IoT Devices from a Web Perspective - Linux Day by Simone Onofri
Attacking IoT Devices from a Web Perspective - Linux Day
Simone Onofri
•
16 views
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院 by IttrainingIttraining
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院
IttrainingIttraining
•
52 views
Transcript: The Details of Description Techniques tips and tangents on altern... by BookNet Canada
Transcript: The Details of Description Techniques tips and tangents on altern...
BookNet Canada
•
136 views
Future of Indian ConsumerTech by Kapil Khandelwal (KK)
Future of Indian ConsumerTech
Kapil Khandelwal (KK)
•
21 views
STPI OctaNE CoE Brochure.pdf by madhurjyapb
STPI OctaNE CoE Brochure.pdf
madhurjyapb
•
14 views
Mastering CSS3 Selectors
1.
hello. Friday, 15 October
2010
2.
Rachel Andrew
@rachelandrew rachelandrew.co.uk edgeofmyseat.com grabaperch.com Friday, 15 October 2010
3.
Mastering
CSS3 Selectors Friday, 15 October 2010
4.
CSS3 is the
next version of CSS Friday, 15 October 2010
5.
CSS3 is Modular Friday,
15 October 2010
6.
Some CSS3 modules
are more complete than others Friday, 15 October 2010
7.
W3C Maturity Levels
Working Draft Candidate Recommendation Proposed Recommendation W3C Recommendation http://www.w3.org/2005/10/Process-20051014/tr#maturity-levels Friday, 15 October 2010
8.
CSS3 is supported
by browsers Some browsers and some (parts of) modules. Friday, 15 October 2010
9.
Using CSS3 Friday, 15
October 2010
10.
Selectors module
W3C Proposed Recommendation http://www.w3.org/TR/css3-selectors/ Friday, 15 October 2010
11.
Basic Selectors
h1 {} p {} .thing {} #uniquething {} .thing p Friday, 15 October 2010
12.
The problem with
CSS2 selectors Friday, 15 October 2010
13.
Adding classes
<h1>My heading</h1> <p class=”first”> ... </p> <p> ... </p> Friday, 15 October 2010
14.
CSS3 Selectors
“Common sense” new selectors target elements more precisely without adding classes Friday, 15 October 2010
15.
Structural pseudo-
class selectors Friday, 15 October 2010
16.
a:link {}
a:visited {} a:hover {} a:active {} Friday, 15 October 2010
17.
:first-child
target an element when it is the first child of a parent element Friday, 15 October 2010
18.
:first-child Friday, 15 October
2010
19.
:first-child
div#wrapper p { ! ! font-size: 1.5em; } Friday, 15 October 2010
20.
:first-child
div#wrapper p:first-child { ! ! font-size: 1.5em; } Friday, 15 October 2010
21.
:first-child Friday, 15 October
2010
22.
:last-child
target an element when it is the last child of a parent element Friday, 15 October 2010
23.
:last-child Friday, 15 October
2010
24.
:last-child
ul#navigation li:last-child { ! ! border-bottom: none; } Friday, 15 October 2010
25.
:last-child Friday, 15 October
2010
26.
:nth-child
select multiple elements according to their position in the document tree Friday, 15 October 2010
27.
:nth-child Friday, 15 October
2010
28.
:nth-child
tr:nth-child(odd) td { ! ! background-color: #f0e9c5; } Friday, 15 October 2010
29.
:nth-child Friday, 15 October
2010
30.
:nth-child
tr:nth-child(3) td { ! ! background-color: #f0e9c5; } Friday, 15 October 2010
31.
:nth-child Friday, 15 October
2010
32.
:nth-child
tr:nth-child(2n+1) td { ! ! background-color: #f0e9c5; } http://reference.sitepoint.com/css/understandingnthchildexpressions Friday, 15 October 2010
33.
:nth-of-type
select multiple elements according to their position in the document tree BUT only those elements that are the same as the type the rule is applied to. Friday, 15 October 2010
34.
:nth-of-type
p:nth-of-type(odd) { ! ! background-color: #f0e9c5; } Friday, 15 October 2010
35.
:nth-of-type Friday, 15 October
2010
36.
:only-child
matches an element if it is the only child element of it’s parent. Friday, 15 October 2010
37.
:only-child
li { ! list-style-type: disc; } ! li:only-child { ! list-style-type: none; } Friday, 15 October 2010
38.
:only-child Friday, 15 October
2010
39.
:empty
matches an element if it is empty Friday, 15 October 2010
40.
:empty
p { ! padding: 0 0 1em 0; ! margin: 0; } ! p:empty { ! padding: 0; } Friday, 15 October 2010
41.
For input elements
Structural pseudo-classes for use with forms. Friday, 15 October 2010
42.
:checked
the checked state of a checkbox or radio button Friday, 15 October 2010
43.
:checked
#agreeterms:checked { border:2px solid blue; } Friday, 15 October 2010
44.
enabled and disabled
detecting input element states Friday, 15 October 2010
45.
:enabled
input:enabled { color: #000; } Friday, 15 October 2010
46.
:disabled
input:disabled { color: #999; } Friday, 15 October 2010
47.
the Negation
pseudo-class :not(selector) Friday, 15 October 2010
48.
:not
<p> ... </p> <p class=”box”> ... </p> <p> ... </p> Friday, 15 October 2010
49.
:not
p:not(.box) { ! padding: 0 0 3em 0; ! margin: 0; } ! p.box { ! border:1px solid #000; ! margin: 0 0 2em 0; } Friday, 15 October 2010
50.
:not Friday, 15 October
2010
51.
Pseudo-elements Friday, 15 October
2010
52.
:first-letter
the first character of the first line of text Friday, 15 October 2010
53.
:first-letter
div#wrapper:first-letter { ! font-size: 200%; ! font-weight: bold; ! color: red; } Friday, 15 October 2010
54.
:first-letter Friday, 15 October
2010
55.
:first-line
the first formatted line of text Friday, 15 October 2010
56.
:first-line
div#wrapper:first-line { ! font-size: 200%; ! font-weight: bold; ! color: red; } Friday, 15 October 2010
57.
:first-line Friday, 15 October
2010
58.
:before
Render content before the element when using generated content Friday, 15 October 2010
59.
:before
<div id=”content”> ... </div> Friday, 15 October 2010
60.
:before
#content:before { content: "Start here:"; } Friday, 15 October 2010
61.
:before Friday, 15 October
2010
62.
:after
Render content after the element when using generated content Friday, 15 October 2010
63.
:after
#content:after { content: "End here:"; } Friday, 15 October 2010
64.
::selection
Content selected in browser by the user Friday, 15 October 2010
65.
::selection
div#wrapper p::selection {! background-color: red; } Friday, 15 October 2010
66.
::selection Friday, 15 October
2010
67.
Combinators
Combining selectors to target elements Friday, 15 October 2010
68.
Descendant Selector
Select all elements that are descendants of a specified parent Friday, 15 October 2010
69.
Descendant Selector
div#wrapper p { ! font-size: 1.5em; } Friday, 15 October 2010
70.
Child Selector
Select all elements that are immediate children of a specified parent Friday, 15 October 2010
71.
Child Selector
<ul> <li>Item 1 <ol> <li>Sub list item 1</li> <li>Sub list item 2</li> </ol> </li> <li>Item 2</li> </ul> Friday, 15 October 2010
72.
Child Selector
li { ! color: #000; } ! ul > li { ! color: red; } Friday, 15 October 2010
73.
Child Selector Friday, 15
October 2010
74.
Adjacent Sibling
Select elements that are the adjacent siblings of an element Friday, 15 October 2010
75.
Adjacent Sibling
div#wrapper h1 + p { ! font-size: 1.5em; } Friday, 15 October 2010
76.
Adjacent Sibling Friday, 15
October 2010
77.
General Sibling
Select elements that are the siblings of an element Friday, 15 October 2010
78.
General Sibling
div#wrapper h2~p { ! color: red; } Friday, 15 October 2010
79.
General Sibling Friday, 15
October 2010
80.
Attribute Selectors
Select elements based on attributes Friday, 15 October 2010
81.
Attribute Selectors
form input[type="text"] { } ! form input[type="submit"] { } Friday, 15 October 2010
82.
Attribute Selectors Friday, 15
October 2010
83.
Attribute Selectors
label[for="fContact"] { ! float: none; ! width: auto; } a[href ^="mailto:"] { ! ! padding-right: 20px; ! ! background-image:url(email.png); ! ! background-repeat: no-repeat; ! ! background-position: right center; } Friday, 15 October 2010
84.
Browser
Support Friday, 15 October 2010
85.
Browser Support Friday, 15
October 2010
86.
Does it
matter? Friday, 15 October 2010
87.
Friday, 15 October
2010
88.
Friday, 15 October
2010
89.
Yes, it
matters. Friday, 15 October 2010
90.
Vendor-specific
extensions Implementing early stage CSS3 Friday, 15 October 2010
91.
border-radius Friday, 15 October
2010
92.
border-radius
.box { -moz-border-radius: 10px; -webkit-border-radius: 10px; border-radius: 10px; } Friday, 15 October 2010
93.
In defence of
vendor- specific extensions Friday, 15 October 2010
94.
JavaScript
Plug the holes in browser support using JavaScript. Friday, 15 October 2010
95.
jQuery: first-child
div#wrapper p:first-child, div#wrapper p.first { ! ! font-size: 1.5em; } <script src="http://code.jquery.com/jquery-latest.js"></ script> <script> $(document).ready(function(){ ! $("div#wrapper p:first-child").addClass("first"); }); </script> Friday, 15 October 2010
96.
jQuery: last-child
ul#navigation li:last-child, ul#navigation li.last { ! ! border-bottom: none; } <script src="http://code.jquery.com/jquery-latest.js"></ script> <script> $(document).ready(function(){ ! $("ul#navigation li:last-child").addClass("last"); }); </script> Friday, 15 October 2010
97.
jQuery: nth-child
tr:nth-child(odd) td, td.odd { ! background-color: #f0e9c5; } <script src="http://code.jquery.com/jquery-latest.js"></ script> <script> $(document).ready(function(){ ! $("tr:nth-child(odd) td").addClass("odd"); }); </script> Friday, 15 October 2010
98.
Scripts that “fix
IE” http://www.keithclark.co.uk/labs/ie-css3/ http://ecsstender.org Friday, 15 October 2010
99.
Thank you. Friday, 15
October 2010