SlideShare a Scribd company logo
BEN KHALFALLAH HÉLA
CSSpatternmatchingrulestoselectelementsinthe
documenttree
CSSSELECTORS
2022
CSSRULESTRUCTURE
selector color : red ; background : yellow ; }
{
HTML TAG, CLASS NAME, UNIVERSAL SELECTOR (*)
PROPERTY
VALUE
DECLARATION
DECLARATION BLOCK
PROPERTY
VALUE
DECLARATION
SELECTORSTYPES
Element selectors


Class selectors


ID selectors


Attribute selectors


Combinators


Pseudo-class selectors


Pseudo-elements selectors
ELEMENTSELECTORS
element { property: value; property: value; }
Any (valid) html tag
h2 { color: silver; } Make the text of all h2 elements in the html
document appear in silver.
h1 { color: gray; }


h2 { color: gray; }


h3 { color: gray; }


h4 { color: gray; }


h5 { color: gray; }


h6 { color: gray; }
h1, h2, h3, h4, h5, h6 {


color: gray;


}
GROUPING SELECTORS
h1 { font: 18px Helvetica; }


h1 { color: purple; }


h1 { background: aqua; }
h1 {


font: 18px Helvetica;


color: purple;


background: aqua;


}
GROUPING DECLARATIONS
CLASSSELECTORS
.class-name { property: value; property: value; }


<p class="legal-notice--description">


Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.


</p>


<span>


Contrary to popular belief, Lorem Ipsum is not simply random text


</span>


<p class="legal-notice--description">


Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium
doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore
veritatis et quasi architecto beatae vitae dicta sunt explicabo.


</p>
.legal-notice--description{


font: 18px Helvetica;


color: purple;


background: aqua;


}
HTML :
CSS :
The css styling will only be applied to the element that has a
class attribute with a value of 'legal-notice--description'.
CASE SENSITIVE SELECTOR
COMBININGELEMENTANDCLASSSELECTORS
element.class-name { property: value; property: value; }
p.legal-notice--description{


font-weight: bold;


}
Rule applies only to a speci
fi
c type of element/class combination, it does
not leak over to other elements.


<p class="legal-notice--description">


Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.


</p>


<span class="legal-notice--description">


Contrary to popular belief, Lorem Ipsum is not simply random text


</span>


<p class="legal-notice--description">


Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium
doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore
veritatis et quasi architecto beatae vitae dicta sunt explicabo.


</p>
The selector will match this element (p having a class with the
value ‘legal-notice—description’).
The selector will match this element (p having a class with the
value ‘legal-notice—description’).
The selector will not match this element (span).
CASE SENSITIVE SELECTOR
MULTIPLECLASSESSELECTORS
.class-name-1.class-name-2….. { property: value; property: value; }
.alert {


font-size: 18px;


}


.error{


background-color: red;


}


.message--body{


font-size: 25px;


}


.alert.error{


font-weight: bold;


}


.alert.error.message--body{


background: white;


}


p.alert.error{


font-weight: lighter;


}
<span class="alert error">


This will match the .alert.error selector


</span>


<span class="error alert">


This will also match the .alert.error selector (order does not matter)


</span>


<span class="alert">


This will match .alert selector


</span>


<span class="error">


This will match .error selector


</span>


<span class="alert error message--body">


This will match .alert.error.message--body selector


</span>


<p class="alert error">


This will match the p.alert.error selector


</p>
The selector will match in any order, but the order in which the style
is applied will change (especially for common properties).
HTML :
CSS :
CASE SENSITIVE SELECTOR
IDSELECTORS
#html-id-value { property: value; property: value; }
#article-title {


font-size: 30px;


font-weight: bold;


background: gainsboro;


}


#article-description{


font-size: 18px;


font-weight: lighter;


background: white;


}
HTML :
CSS :
<h4 id="article-title">


1914 translation by H. Rackham


</h4>


<p id="article-description">


Lorem ipsum dolor sit amet, consectetur adipiscing elit.


Sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua.


Ut enim ad minim veniam, quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea commodo consequat.


</p>


ID selectors can’t be combined with other IDs.


id attribute must match exactly the value given in the selector.


There should be only one element with a given ID in a document.
CASE SENSITIVE SELECTOR
IT’S NOT RECOMMENDED TO USE ID
SELECTORS, THEY ARE LESS FLEXIBLE,
HARD TO OVERRIDE (HIGHER SPECIFICITY
THAN CLASSES).
ATTRIBUTESELECTORS
Match elements that have a certain attribute with any value :
p[class]{


color: purple;


}
Select all p elements that
have a class attribute with
any value and make their text
color purple.
a[href][title]{


color: green;


}
<p class="error">Oups, this page is not available !</p>
Html tag (element)
Attribute
Content
attribute-name="attribute-value"
= End of html tag
<a


href="https://example.com"


title="Example Home Page"


>


Website (with title)


</a>


<a


href="https://new-site.com"


title="New Site Page"


>


New Website (with title)


</a>
Select any html hyperlink that has both an href and a title attribute (with any value) and make their
text color green.
<a


href="https://my-site.org"


>


Website (without title)


</a>


<a


title="This is not a link"


>


Incorrect link !


</a>
ATTRIBUTESELECTORS
Match elements that have a certain attribute with an exact value :
<p class="error">Oups, this page is not available !</p>
Html tag (element)
Attribute
Content
attribute-name="attribute-value"
= End of html tag
p[class="error"]{


color: purple;


}
Select all p elements that
have a class attribute with
exactly the value ‘error’ and
make their text color purple.
<a


href="https://example.com"


title="Example Home Page"


>


Website (with title)


</a>
a[href="https://example.com"][title="Example Home Page"]{


color: green;


}
CASE SENSITIVE SELECTOR
<a


href="https://new-site.com"


title="New Site Page"


>


New Website (with title)


</a>


<a


href="https://my-site.org"


>


Website (without title)


</a>


<a


title="This is not a link"


>


Incorrect link !


</a>
Select any html hyperlink that has an href attribute with exactly the value ‘https://example.com’ and a
title attribute with exactly the value ‘Example Home Page’ and make their text color green.
ATTRIBUTESELECTORS
Matching one word in a space-separated list (~) :
CASE SENSITIVE SELECTOR
<p


class="alert urgent info"


>


The is an information message!


</p>


<p


class="alert urgent warning"


>


The resource took too long to load!


</p>


<p


class="alert urgent error"


>


The service is unavailable at the moment


</p>
p[class~="alert"] {


color: purple;


font-weight: bold;


font-size: 18px;


}


p[class~="warning"] {


color: orange;


font-size: 12px;


}


p[class~="error"] {


color: red;


}
Select all p elements whose class attribute contains the word ‘alert’.
Select all p elements whose class attribute contains the word ‘warning’.
Select all p elements whose class attribute contains the word ‘error’.
a[title~="Nasa"] {


color: green;


font-weight: light;


font-size: 15px;


}
<a


href="https://www.nasa.gov/missions"


title="Nasa Missions Page"


>


Nasa Missions Page


</a>
<a


href="https://www.nasa.gov/"


title="Nasa Home Page"


>


Nasa Home Page


</a>
<a


href="https://www.spacex.com/"


title="Space X Home Page"


>


Space X Home Page


</a>
Space separated list
Space separated list
Space separated list
title="Nasa Missions Page"
title="NasaMissions Page"
title="Nasa-Missions Page"
THE ORDER OF SELECTORS MATTER !
The word only matches inside a space-separated list (case sensitive).
title="nasa Missions Page"
ATTRIBUTESELECTORS
Matching a substring within an attribute value (*) :
CASE SENSITIVE SELECTOR
THE ORDER OF SELECTORS MATTER !
<h4 class="article-details article-title">


1914 translation by H. Rackham


</h4>


<p class="article-details article-description">


Lorem ipsum dolor sit amet, consectetur adipiscing elit.


Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.


Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi
ut aliquip ex ea commodo consequat.


</p>


<img


class="article-image"


alt="mission"


src="https://science.nasa.gov/files/science-pink/s3fs-public/styles/
large/public/thumbnails/image/ACE_0.jpg?itok=t2wtXFRN"


/>
h4[class*="details"] {


color: blue;


font-weight: bold;


font-size: 25px;


}


p[class*="details"] {


color: darkgray;


font-weight: light;


font-size: 15px;


}


*[class*="details"] {


text-decoration: underline;


}


*[class*="image"] {


width: 10rem;


height: 10rem;


}


Select all h4 elements whose class attribute contains the
substring ‘details’.
Select all p elements whose class attribute contains the
substring ‘details’.
Select all elements whose class attribute contains the
substring ‘details’.
Select all elements whose class attribute contains the
substring ‘image’.
h4[class~="details"] {


color: blue;


font-weight: bold;


font-size: 25px;


}
~ doesn’t much substring but one word in a
space-separated list.
input[title*="format"] {


background-color: red;


}
<input


type="tel"


title="Telephone number should be formatted as XXX-XXX-XXXX"


pattern="d{3}-d{3}-d{4}"


/>
<input


type="email"


title="Email is a mandatory field"


required


/>
img[class*="image"][alt*="details"] {


width: 20rem;


height: 20rem;


}


img[class~="article-image"][alt*="details"] {


width: 20rem;


height: 20rem;


}
Combining selectors
ATTRIBUTESELECTORS
Matching a substring at the beginning of an attribute value (^) :
CASE SENSITIVE SELECTOR
<img


class="article-details article-image"


alt="ps5-console"


src="https://pbs.twimg.com/media/EiGQrbFXsAAzrpq?format=jpg&name=small"


/>


<img


class="article-details article-image"


alt="xbox-activision"


src="https://image.jeuxvideo.com/medias-md/164253/1642526486-8301-card.jpg"


/>


<img


class="article-details article-image"


alt="xbox-serie-x"


src="https://static.actu.fr/uploads/2019/04/8c976cba-12d8-42ca-b419-c177f84b66bf.jpg"


/>


<img


class="article-details article-image"


alt="kindle-paperwhite"


src="https://img.20mn.fr/zBDkMRUzTDerDDNSZYSbWSk/648x415"


/>
img[alt^="xbox"] {


width: 30rem;


height: 30rem;


border: 2px solid red;


}
Selecting all img elements whose alt attribute starts with ‘xbox’.
<img


class="article-details article-image"


alt="xbox-activision game"


src="https://image.jeuxvideo.com/medias-md/164253/1642526486-8301-card.jpg"


/>
<img


class="article-details article-image"


alt="game xbox-serie-x"


src="https://static.actu.fr/uploads/2019/04/8c976cba-12d8-42ca-b419-c177f84b66bf.jpg"


/>
*[class^="alert"] {


border: 2px solid red;


}
<span class="alert error">


This will match the selector


</span>
<span class="error alert">


This will not match the selector


</span>
<p class="alert">


This will match the selector


</p>


<span class="alerterror">


This will match the selector


</span>


<span class="alert-error">


This will match the selector


</span>
<p class="Alert">


This will match the selector


</p>
ATTRIBUTESELECTORS
Matching a substring at the end of an attribute value ($) :
CASE SENSITIVE SELECTOR
<img


alt="X-ray glow"


src="https://www.sciencenews.org/wp-content/uploads/2022/01/012022_LK_COW_feat-1030x580.jpg"


/>


<img


alt="Neutron star collisions"


src=« https://www.sciencenews.org/wp-content/uploads/2021/11/110221_ec_heavy-elements_feat-1030x580.gif"


/>


<img


alt="Intense drought or flash floods"


src="https://www.sciencenews.org/wp-content/uploads/2022/01/011421_CG_flooding_feat-1030x580.png"


/>


<img


alt="The first magnetar flare"


src="https://www.sciencenews.org/wp-content/uploads/2021/01/011421_lg_magnetar_feat-1030x580.jpg"


/>
img[src$=".jpg"] {


width: 10rem;


height: 10rem;


border: 2px solid red;


}


img[src$=".png"] {


width: 15rem;


height: 15rem;


border: 2px solid yellow;


}
a[href$=".pdf"] {


border: 2px solid purple;


}
<a


href="https://cfm.ehu.es/ricardo/docs/python/Learning_Python.pdf"


title="Learning Python"


>


Learning Python


</a>
<a


href="https://cfm.ehu.es/ricardo/docs/python/Learning_Python.PDF"


title="Learning Python"


>


Learning Python


</a>
<a


href="https://cfm.ehu.es/ricardo/docs/python/Learning_Python.csv"


title="Learning Python"


>


Learning Python Stats


</a>
ATTRIBUTESELECTORS
Case insensitive identi
fi
er (i) :
a[href$=".pdf" i] {


border: 2px solid purple;


}
<a


href="https://cfm.ehu.es/ricardo/docs/python/Learning_Python.pdf"


title="Learning Python"


>


Learning Python


</a>
<a


href="https://cfm.ehu.es/ricardo/docs/python/Learning_Python.PDF"


title="Learning Python"


>


Learning Python


</a>
a[title~="Nasa" i] {


color: green;


font-weight: light;


font-size: 15px;


}
<a


href="https://www.nasa.gov/"


title="Nasa Home Page"


>


Nasa Home Page


</a>
<a


href="https://www.nasa.gov/missions"


title="nasa Misions Page"


>


Nasa Misions Page


</a>
input[title*="format" i] {


background-color: red;


}
<input


type="tel"


title="Phone number should be formatted as XXX-XXX-XXXX"


pattern="d{3}-d{3}-d{4}"


/>
<input


type="tel"


title="phone number should be Formatted as XXX-XXX-XXXX"


pattern="d{3}-d{3}-d{4}"


/>
ATTRIBUTESELECTORS(RECAP)
[my-attribute="attribute-value"]
Select any element with an attribute 'my-attribute'
whose value is exactly equal to ‘attribute-value'.
[my-attribute~="attribute-value"]
Select any element with an attribute ‘my-attribute’
whose value contains the word ‘attribute-value’ in
a space-separated list of words.
[my-attribute*="attribute-value"]
Select any element with an attribute 'my-attribute'
whose value contains the substring ‘attribute-
value'.
[my-attribute^="attribute-value"]
Select any element with an attribute 'my-attribute'
whose value begins with ‘attribute-value'.
[my-attribute$="attribute-value"]
Select any element with an attribute 'my-attribute'
whose value end with ‘attribute-value'.
[my-attribute="attribute-value" i] Case insensitive identi
fi
er (i)
DESCENDANTCOMBINATOR
selector1 selector2 { property: value; }
div span {


color: red;


}
Set the text color to red for any span
element descending from div
<div>


<h4>


1914 translation by H. Rackham


</h4>


<span>


1. This will match


</span>


<span>


<span>


2. This will match


</span>


</span>


</div>
<div>


<p>


<span>3.This will match</span>


</p>


</div>
.article-details span {


color: red;


}
Selector can be class names
<div className="article-details">


<span>


<span>


1. This will match


</span>


</span>


<p>


<span>


<span>


2. This will match


</span>


</span>


</p>


</div>
CHILDCOMBINATOR
selector1 > selector2 { property: value; }
div > span {


color: red;


}
Set the text color to red for any span
element descending from div
<div>


<h4>


1914 translation by H. Rackham


</h4>


<span>


1. This will match


</span>


<span>


<span>


2. This will match


</span>


</span>


</div>
<div>


<p>


<span>3.This will not match</span>


</p>


</div>
( stricter than the descendant combinator )
Elements matched by the second selector must be the immediate
children of the elements matched by the
fi
rst selector :
.article-details > span {


color: red;


}
Selector can be class names
<div>


<h4>


1914 translation by H. Rackham


</h4>


<span>


1. This will not match


</span>


<div className="article-details">


<span>


<span>


2. This will match


</span>


</span>


</div>


</div>
<div>


<p>


<span>3.This will not match</span>


</p>


</div>
ADJACENTSIBLINGCOMBINATOR
former_element + target_element { property: value; }
Select an element that immediately follows another element with the same parent :
h1 + p {


margin-top: 0;


}
Remove the top margin from a paragraph
immediately following an h1 .
Select any p element that immediately follows an h1
element that shares a parent with the p element.
<div>


<h1>


1914 translation by H. Rackham


</h1>


<p>


This paragraph will match


</p>


<p>


This will not match


</p>


</div>
This p isn’t immediately after h1.
GENERALSIBLINGCOMBINATOR
former_element ~ target_element { property: value; }
Select an element that follows another element when both elements share the same parent :
h2 ~ ol {


font-style: italic;


}
The two elements do not need to be adjacent sibling.
Italicize any ol element that follows an h2 element
and also share a parent with h2.
<div>


<h2>


1914 translation by H. Rackham


</h2>


<p>


Contrary to popular belief, Lorem Ipsum is not simply random text.


</p>


<ol>


<li>1. This will match</li>


<li>2. This will match</li>


<li>3. This will match</li>


</ol>


<p>


Contrary to popular belief, Lorem Ipsum is not simply random text.


</p>


<ol>


<li>4. This will match</li>


<li>5. This will match</li>


<li>6. This will match</li>


</ol>


<div>


<ol>


<li>1. This will not match</li>


<li>2. This will not match</li>


<li>3. This will not match</li>


</ol>


</div>


</div>


Follows h2 + shares the same parent
Follows h2 + shares the same parent
Follows h2 but doesn’t shares the same parent
SELECTINGEMPTYELEMENTS
element:empty { property: value; }
Select any element that has no children of any kind, including text nodes (text and whitespace) :
<div>


<p></p>


<p> </p>


<p>




</p>


<p><!--This is a comment--></p>


</div>
This will match
This will not match (white space)
This will not match
This will match (comments are not considered content).
*: empty { display:none;} can hide elements like input,
img, text area, because they don’t have children.
p:empty {


display: none;


}
SELECTINGUNIQUECHILDREN
Select elements when they are the only child element of another element :
element:only-child { property: value; }
img:only-child {


border: 1px solid red;


}
<a href="http://w3.org/">


<img


src="w3.png"


alt="W3C"


/>


</a>
<a href="http://w3.org/">


<img


src="w3.png"


alt="W3C"


/>


<em>The W3C</em>


</a>
This will match : img is the only child of a.
This will not match : img isn’t the only child of a.
Select img that are the only child.
<ol>


<li>


First


<ul>


<li>This list has just one element.</li>


</ul>


</li>


<li>


Second


<ul>


<li>This list has three elements.</li>


<li>This list has three elements.</li>


<li>This list has three elements.</li>


</ul>


</li>


</ol>
li:only-child {


color: red;


list-style-type: square;


}
SELECTINGFIRSTCHILDREN
Select elements that are the
fi
rst children of others elements :
element:
fi
rst-child { property: value; }
<div>


<p>This text is selected!</p>


<p>This text isn't selected.</p>


</div>


<div>


<h2>This text isn't selected: it's not a `p`.</h2>


<p>This text isn't selected.</p>


</div>
p:first-child {


color: lime;


background-color: black;


padding: 5px;


}
ul li:first-child {


color: red;


font-weight: bold;


}
<ul>


<li>Item 1</li>


<li>Item 2</li>


<li>


Item 3


<ul>


<li>Item 3.1</li>


<li>Item 3.2</li>


<li>Item 3.3</li>


</ul>


</li>


</ul>
SELECTINGLASTCHILDREN
Select elements that are the last children of others elements :
element:last-child { property: value; }
<div>


<p>This text isn't selected.</p>


<p>This text is selected!</p>


</div>


<div>


<p>This text isn't selected.</p>


<h2>This text isn't selected: it's not a `p`.</h2>


</div>
p:last-child {


color: lime;


background-color: black;


padding: 5px;


}
<ul>


<li>Item 1</li>


<li>Item 2</li>


<li>


Item 3


<ul>


<li>Item 3.1</li>


<li>Item 3.2</li>


<li>Item 3.3</li>


</ul>


</li>


</ul>
ul li:last-child {


border: 1px solid red;


color: red;


}
SELECTINGEVERYnthCHILDREN
Select elements based on their position among a group of siblings :
element:nth-child(number) { property: value; }
element:nth-child(odd) { property: value; }
element:nth-child(even) { property: value; }
element:nth-child(a * n + b) { property: value; }
element:nth-last-child(number) { property: value; }
element:nth-last-child(odd) { property: value; }
element:nth-last-child(even) { property: value; }
element:nth-last-child(a * n + b) { property: value; }
Count start from top to bottom Count start from bottom to top
n starts from 0 n starts from 0
NEGATIONPSEUDO-CLASS
element:not(selector) { property: value; }
.moreinfo:not(li) {


font-style: italic;


}
Select all elements with a class whose value contains the word
‘moreinfo’ as long as they are not li elements
p:not(:not(p))
Cannot be nested
*.article-link:not(li):not(p){


color: red;


}
Select all elements with class ‘article-link’ that are neither list items
nor paragraphs.
HYPERLINKPSEUDO-CLASSES
:link Matches links that have not yet been visited.
:visited Matches links that have been visited.
a:link{


color: blue;


}


a:visited{


color: red;


}
a.article-details-link:link, a[href^="http"]:link {


color: slateblue;


}


a.article-details-link:visited, a[href^="http"]:visited {


color: maroon;


}
a#article-link-id:link {


color: yellow;


}


a#article-link-id:visited {


color: gray;


}
Class name selectors Element ID selectors
USERACTIONPSEUDO-CLASSES
:hover Matches when an element is hovered.
:active
Matches when an item is being activated by the
user, for example clicked on.
:focus Matches when an element has focus.
UI-STATEPSEUDO-CLASSES
:enabled Represents a user interface element that is in an enabled state.
:disabled Represents a user interface element that is in a disabled state.
:read-only Represents any element that cannot be changed by the user.
:read-write Represents any element that is user-editable.
:checked
Matches when elements such as checkboxes and radiobuttons are
toggled on.
:indeterminate Matches when UI elements are in an indeterminate state.
:default
Matches one or more UI elements that are the default among a set of
elements.
:valid Matches an element with valid contents.
:invalid Matches an element with invalid contents.
:in-range
Applies to elements with range limitations, for example a slider control,
when the selected value is in the allowed range.
:out-of-range
Applies to elements with range limitations, for example a slider control,
when the selected value is outside the allowed range.
:required Matches when a form element is required.
:optional Matches when a form element is optional.
BEFORE&AFTERPSEUDOELEMENTSSELECTORS
::before
Inserts something before the content of each selected
element(s).


p::before {


content: "Read this: ";


}
::after
Inserts something after the content of each selected
element(s).


p::after {


content: " - Remember this";


}
FIRSTLETTERPSEUDOELEMENTSELECTOR
p::first-letter{


color: red;


}


p:first-of-type::first-letter{


font-size: 200%;


}
FIRSTLINEPSEUDOELEMENTSELECTOR
p::first-line{


font-size: 150%;


color: purple;


}

More Related Content

What's hot

Web html table tags
Web html  table tagsWeb html  table tags
Web html table tags
Kainat Ilyas
 
(Fast) Introduction to HTML & CSS
(Fast) Introduction to HTML & CSS (Fast) Introduction to HTML & CSS
(Fast) Introduction to HTML & CSS
Dave Kelly
 
CSS
CSSCSS
Cascading style sheet
Cascading style sheetCascading style sheet
Cascading style sheet
Michael Jhon
 
CSS Transitions, Transforms, Animations
CSS Transitions, Transforms, Animations CSS Transitions, Transforms, Animations
CSS Transitions, Transforms, Animations
Rob LaPlaca
 
JavaScript Programming
JavaScript ProgrammingJavaScript Programming
JavaScript Programming
Sehwan Noh
 
How Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) WorksHow Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) Works
Amit Tyagi
 
Dom(document object model)
Dom(document object model)Dom(document object model)
Dom(document object model)
Partnered Health
 
Document Object Model (DOM)
Document Object Model (DOM)Document Object Model (DOM)
Document Object Model (DOM)
GOPAL BASAK
 
Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)
Chris Poteet
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
Amit Tyagi
 
CSS INHERITANCE
CSS INHERITANCECSS INHERITANCE
CSS INHERITANCE
Anuradha
 
Javascript operators
Javascript operatorsJavascript operators
Javascript operatorsMohit Rana
 
Document object model
Document object modelDocument object model
Document object model
Amit kumar
 

What's hot (20)

Html frames
Html framesHtml frames
Html frames
 
Web html table tags
Web html  table tagsWeb html  table tags
Web html table tags
 
CSS
CSSCSS
CSS
 
(Fast) Introduction to HTML & CSS
(Fast) Introduction to HTML & CSS (Fast) Introduction to HTML & CSS
(Fast) Introduction to HTML & CSS
 
Java script
Java scriptJava script
Java script
 
CSS
CSSCSS
CSS
 
Introduction to HTML and CSS
Introduction to HTML and CSSIntroduction to HTML and CSS
Introduction to HTML and CSS
 
Cascading style sheet
Cascading style sheetCascading style sheet
Cascading style sheet
 
Html
HtmlHtml
Html
 
CSS Transitions, Transforms, Animations
CSS Transitions, Transforms, Animations CSS Transitions, Transforms, Animations
CSS Transitions, Transforms, Animations
 
JavaScript Programming
JavaScript ProgrammingJavaScript Programming
JavaScript Programming
 
How Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) WorksHow Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) Works
 
Dom(document object model)
Dom(document object model)Dom(document object model)
Dom(document object model)
 
Css Ppt
Css PptCss Ppt
Css Ppt
 
Document Object Model (DOM)
Document Object Model (DOM)Document Object Model (DOM)
Document Object Model (DOM)
 
Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
 
CSS INHERITANCE
CSS INHERITANCECSS INHERITANCE
CSS INHERITANCE
 
Javascript operators
Javascript operatorsJavascript operators
Javascript operators
 
Document object model
Document object modelDocument object model
Document object model
 

Similar to CSS selectors

An Introduction to Cascading Style Sheets (CSS3)
An Introduction to Cascading Style Sheets (CSS3)An Introduction to Cascading Style Sheets (CSS3)
An Introduction to Cascading Style Sheets (CSS3)
Ardee Aram
 
HTML and CSS part 2
HTML and CSS part 2HTML and CSS part 2
HTML and CSS part 2
Julie Iskander
 
KMUTNB - Internet Programming 4/7
KMUTNB - Internet Programming 4/7KMUTNB - Internet Programming 4/7
KMUTNB - Internet Programming 4/7
phuphax
 
CSS3 and Selectors
CSS3 and SelectorsCSS3 and Selectors
CSS3 and Selectors
Rachel Andrew
 
The road to &lt;> styled-components: CSS in component-based systems by Max S...
The road to &lt;> styled-components: CSS in component-based systems by Max S...The road to &lt;> styled-components: CSS in component-based systems by Max S...
The road to &lt;> styled-components: CSS in component-based systems by Max S...
React London 2017
 
Sass Essentials
Sass EssentialsSass Essentials
Sass Essentials
romiguelangel
 
Broadleaf Presents Thymeleaf
Broadleaf Presents ThymeleafBroadleaf Presents Thymeleaf
Broadleaf Presents Thymeleaf
Broadleaf Commerce
 
CSS for Developers
CSS for DevelopersCSS for Developers
CSS for Developers
Nascenia IT
 
Cascading Style Sheets - Part 01
Cascading Style Sheets - Part 01Cascading Style Sheets - Part 01
Cascading Style Sheets - Part 01
Hatem Mahmoud
 
9- Learn CSS Fundamentals / Pseudo-classes
9- Learn CSS Fundamentals / Pseudo-classes9- Learn CSS Fundamentals / Pseudo-classes
9- Learn CSS Fundamentals / Pseudo-classes
In a Rocket
 
16-DOMTree.pptx
16-DOMTree.pptx16-DOMTree.pptx
16-DOMTree.pptx
KhushiSingla10
 
HTML FOR BEGINNERS AND FOR PRACTICE .pdf
HTML FOR BEGINNERS AND FOR PRACTICE .pdfHTML FOR BEGINNERS AND FOR PRACTICE .pdf
HTML FOR BEGINNERS AND FOR PRACTICE .pdf
Arun Karthik
 
Wordpress plugin development from Scratch
Wordpress plugin development from ScratchWordpress plugin development from Scratch
Wordpress plugin development from Scratch
Ocaka Alfred
 
Exam 70 480 CSS3 at Jinal Desai .NET
Exam 70 480 CSS3 at Jinal Desai .NETExam 70 480 CSS3 at Jinal Desai .NET
Exam 70 480 CSS3 at Jinal Desai .NET
jinaldesailive
 
GDI Seattle - Intro to JavaScript Class 4
GDI Seattle - Intro to JavaScript Class 4GDI Seattle - Intro to JavaScript Class 4
GDI Seattle - Intro to JavaScript Class 4
Heather Rock
 
Zend framework 04 - forms
Zend framework 04 - formsZend framework 04 - forms
Zend framework 04 - forms
Tricode (part of Dept)
 
Css Selectors
Css SelectorsCss Selectors
Css Selectors
Igor Ognichenko
 
Software programming tools for creating/managing CSS files
Software programming tools for creating/managing CSS filesSoftware programming tools for creating/managing CSS files
Software programming tools for creating/managing CSS filesDinu Suman
 
Html advance
Html advanceHtml advance
Html advance
PumoTechnovation
 

Similar to CSS selectors (20)

An Introduction to Cascading Style Sheets (CSS3)
An Introduction to Cascading Style Sheets (CSS3)An Introduction to Cascading Style Sheets (CSS3)
An Introduction to Cascading Style Sheets (CSS3)
 
HTML and CSS part 2
HTML and CSS part 2HTML and CSS part 2
HTML and CSS part 2
 
KMUTNB - Internet Programming 4/7
KMUTNB - Internet Programming 4/7KMUTNB - Internet Programming 4/7
KMUTNB - Internet Programming 4/7
 
CSS3 and Selectors
CSS3 and SelectorsCSS3 and Selectors
CSS3 and Selectors
 
The road to &lt;> styled-components: CSS in component-based systems by Max S...
The road to &lt;> styled-components: CSS in component-based systems by Max S...The road to &lt;> styled-components: CSS in component-based systems by Max S...
The road to &lt;> styled-components: CSS in component-based systems by Max S...
 
Sass Essentials
Sass EssentialsSass Essentials
Sass Essentials
 
Broadleaf Presents Thymeleaf
Broadleaf Presents ThymeleafBroadleaf Presents Thymeleaf
Broadleaf Presents Thymeleaf
 
CSS for Developers
CSS for DevelopersCSS for Developers
CSS for Developers
 
Cascading Style Sheets - Part 01
Cascading Style Sheets - Part 01Cascading Style Sheets - Part 01
Cascading Style Sheets - Part 01
 
9- Learn CSS Fundamentals / Pseudo-classes
9- Learn CSS Fundamentals / Pseudo-classes9- Learn CSS Fundamentals / Pseudo-classes
9- Learn CSS Fundamentals / Pseudo-classes
 
Id and class selector
Id and class selectorId and class selector
Id and class selector
 
16-DOMTree.pptx
16-DOMTree.pptx16-DOMTree.pptx
16-DOMTree.pptx
 
HTML FOR BEGINNERS AND FOR PRACTICE .pdf
HTML FOR BEGINNERS AND FOR PRACTICE .pdfHTML FOR BEGINNERS AND FOR PRACTICE .pdf
HTML FOR BEGINNERS AND FOR PRACTICE .pdf
 
Wordpress plugin development from Scratch
Wordpress plugin development from ScratchWordpress plugin development from Scratch
Wordpress plugin development from Scratch
 
Exam 70 480 CSS3 at Jinal Desai .NET
Exam 70 480 CSS3 at Jinal Desai .NETExam 70 480 CSS3 at Jinal Desai .NET
Exam 70 480 CSS3 at Jinal Desai .NET
 
GDI Seattle - Intro to JavaScript Class 4
GDI Seattle - Intro to JavaScript Class 4GDI Seattle - Intro to JavaScript Class 4
GDI Seattle - Intro to JavaScript Class 4
 
Zend framework 04 - forms
Zend framework 04 - formsZend framework 04 - forms
Zend framework 04 - forms
 
Css Selectors
Css SelectorsCss Selectors
Css Selectors
 
Software programming tools for creating/managing CSS files
Software programming tools for creating/managing CSS filesSoftware programming tools for creating/managing CSS files
Software programming tools for creating/managing CSS files
 
Html advance
Html advanceHtml advance
Html advance
 

More from Héla Ben Khalfallah

DATABASE_DATA_STRUCTURE_DEVOXXFRANCE2024.pdf
DATABASE_DATA_STRUCTURE_DEVOXXFRANCE2024.pdfDATABASE_DATA_STRUCTURE_DEVOXXFRANCE2024.pdf
DATABASE_DATA_STRUCTURE_DEVOXXFRANCE2024.pdf
Héla Ben Khalfallah
 
Yo messapp
Yo messappYo messapp
Elixir cheatsheet
Elixir cheatsheetElixir cheatsheet
Elixir cheatsheet
Héla Ben Khalfallah
 
Elixir in a nutshell - Fundamental Concepts
Elixir in a nutshell - Fundamental ConceptsElixir in a nutshell - Fundamental Concepts
Elixir in a nutshell - Fundamental Concepts
Héla Ben Khalfallah
 
Elixir in a nutshell - Ecosystem (session 1)
Elixir in a nutshell - Ecosystem (session 1)Elixir in a nutshell - Ecosystem (session 1)
Elixir in a nutshell - Ecosystem (session 1)
Héla Ben Khalfallah
 
FP Using ES6+ (Cheat Sheet)
FP Using ES6+ (Cheat Sheet)FP Using ES6+ (Cheat Sheet)
FP Using ES6+ (Cheat Sheet)
Héla Ben Khalfallah
 
WONC DOVA
WONC DOVAWONC DOVA
Process & Methodologies (1.2)
Process & Methodologies (1.2)Process & Methodologies (1.2)
Process & Methodologies (1.2)
Héla Ben Khalfallah
 
Process & Methodologies (1.1)
Process & Methodologies (1.1)Process & Methodologies (1.1)
Process & Methodologies (1.1)
Héla Ben Khalfallah
 
Process & Methodologies (1.0)
Process & Methodologies (1.0)Process & Methodologies (1.0)
Process & Methodologies (1.0)
Héla Ben Khalfallah
 
La gestion en boucle fermée
La gestion en boucle ferméeLa gestion en boucle fermée
La gestion en boucle fermée
Héla Ben Khalfallah
 
Les règles de développement Angular
Les règles de développement AngularLes règles de développement Angular
Les règles de développement Angular
Héla Ben Khalfallah
 
Architecture ASIS (iOS)
Architecture ASIS (iOS)Architecture ASIS (iOS)
Architecture ASIS (iOS)
Héla Ben Khalfallah
 

More from Héla Ben Khalfallah (13)

DATABASE_DATA_STRUCTURE_DEVOXXFRANCE2024.pdf
DATABASE_DATA_STRUCTURE_DEVOXXFRANCE2024.pdfDATABASE_DATA_STRUCTURE_DEVOXXFRANCE2024.pdf
DATABASE_DATA_STRUCTURE_DEVOXXFRANCE2024.pdf
 
Yo messapp
Yo messappYo messapp
Yo messapp
 
Elixir cheatsheet
Elixir cheatsheetElixir cheatsheet
Elixir cheatsheet
 
Elixir in a nutshell - Fundamental Concepts
Elixir in a nutshell - Fundamental ConceptsElixir in a nutshell - Fundamental Concepts
Elixir in a nutshell - Fundamental Concepts
 
Elixir in a nutshell - Ecosystem (session 1)
Elixir in a nutshell - Ecosystem (session 1)Elixir in a nutshell - Ecosystem (session 1)
Elixir in a nutshell - Ecosystem (session 1)
 
FP Using ES6+ (Cheat Sheet)
FP Using ES6+ (Cheat Sheet)FP Using ES6+ (Cheat Sheet)
FP Using ES6+ (Cheat Sheet)
 
WONC DOVA
WONC DOVAWONC DOVA
WONC DOVA
 
Process & Methodologies (1.2)
Process & Methodologies (1.2)Process & Methodologies (1.2)
Process & Methodologies (1.2)
 
Process & Methodologies (1.1)
Process & Methodologies (1.1)Process & Methodologies (1.1)
Process & Methodologies (1.1)
 
Process & Methodologies (1.0)
Process & Methodologies (1.0)Process & Methodologies (1.0)
Process & Methodologies (1.0)
 
La gestion en boucle fermée
La gestion en boucle ferméeLa gestion en boucle fermée
La gestion en boucle fermée
 
Les règles de développement Angular
Les règles de développement AngularLes règles de développement Angular
Les règles de développement Angular
 
Architecture ASIS (iOS)
Architecture ASIS (iOS)Architecture ASIS (iOS)
Architecture ASIS (iOS)
 

Recently uploaded

Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Jay Das
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
Tendenci - The Open Source AMS (Association Management Software)
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
IES VE
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
informapgpstrackings
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
RISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent EnterpriseRISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent Enterprise
Srikant77
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 

Recently uploaded (20)

Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
RISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent EnterpriseRISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent Enterprise
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 

CSS selectors

  • 2. CSSRULESTRUCTURE selector color : red ; background : yellow ; } { HTML TAG, CLASS NAME, UNIVERSAL SELECTOR (*) PROPERTY VALUE DECLARATION DECLARATION BLOCK PROPERTY VALUE DECLARATION
  • 3. SELECTORSTYPES Element selectors Class selectors ID selectors Attribute selectors Combinators Pseudo-class selectors Pseudo-elements selectors
  • 4. ELEMENTSELECTORS element { property: value; property: value; } Any (valid) html tag h2 { color: silver; } Make the text of all h2 elements in the html document appear in silver. h1 { color: gray; } h2 { color: gray; } h3 { color: gray; } h4 { color: gray; } h5 { color: gray; } h6 { color: gray; } h1, h2, h3, h4, h5, h6 { color: gray; } GROUPING SELECTORS h1 { font: 18px Helvetica; } h1 { color: purple; } h1 { background: aqua; } h1 { font: 18px Helvetica; color: purple; background: aqua; } GROUPING DECLARATIONS
  • 5. CLASSSELECTORS .class-name { property: value; property: value; } <p class="legal-notice--description"> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </p> <span> Contrary to popular belief, Lorem Ipsum is not simply random text </span> <p class="legal-notice--description"> Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. </p> .legal-notice--description{ font: 18px Helvetica; color: purple; background: aqua; } HTML : CSS : The css styling will only be applied to the element that has a class attribute with a value of 'legal-notice--description'. CASE SENSITIVE SELECTOR
  • 6. COMBININGELEMENTANDCLASSSELECTORS element.class-name { property: value; property: value; } p.legal-notice--description{ font-weight: bold; } Rule applies only to a speci fi c type of element/class combination, it does not leak over to other elements. <p class="legal-notice--description"> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </p> <span class="legal-notice--description"> Contrary to popular belief, Lorem Ipsum is not simply random text </span> <p class="legal-notice--description"> Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. </p> The selector will match this element (p having a class with the value ‘legal-notice—description’). The selector will match this element (p having a class with the value ‘legal-notice—description’). The selector will not match this element (span). CASE SENSITIVE SELECTOR
  • 7. MULTIPLECLASSESSELECTORS .class-name-1.class-name-2….. { property: value; property: value; } .alert { font-size: 18px; } .error{ background-color: red; } .message--body{ font-size: 25px; } .alert.error{ font-weight: bold; } .alert.error.message--body{ background: white; } p.alert.error{ font-weight: lighter; } <span class="alert error"> This will match the .alert.error selector </span> <span class="error alert"> This will also match the .alert.error selector (order does not matter) </span> <span class="alert"> This will match .alert selector </span> <span class="error"> This will match .error selector </span> <span class="alert error message--body"> This will match .alert.error.message--body selector </span> <p class="alert error"> This will match the p.alert.error selector </p> The selector will match in any order, but the order in which the style is applied will change (especially for common properties). HTML : CSS : CASE SENSITIVE SELECTOR
  • 8. IDSELECTORS #html-id-value { property: value; property: value; } #article-title { font-size: 30px; font-weight: bold; background: gainsboro; } #article-description{ font-size: 18px; font-weight: lighter; background: white; } HTML : CSS : <h4 id="article-title"> 1914 translation by H. Rackham </h4> <p id="article-description"> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </p> ID selectors can’t be combined with other IDs. id attribute must match exactly the value given in the selector. There should be only one element with a given ID in a document. CASE SENSITIVE SELECTOR IT’S NOT RECOMMENDED TO USE ID SELECTORS, THEY ARE LESS FLEXIBLE, HARD TO OVERRIDE (HIGHER SPECIFICITY THAN CLASSES).
  • 9. ATTRIBUTESELECTORS Match elements that have a certain attribute with any value : p[class]{ color: purple; } Select all p elements that have a class attribute with any value and make their text color purple. a[href][title]{ color: green; } <p class="error">Oups, this page is not available !</p> Html tag (element) Attribute Content attribute-name="attribute-value" = End of html tag <a href="https://example.com" title="Example Home Page" > Website (with title) </a> <a href="https://new-site.com" title="New Site Page" > New Website (with title) </a> Select any html hyperlink that has both an href and a title attribute (with any value) and make their text color green. <a href="https://my-site.org" > Website (without title) </a> <a title="This is not a link" > Incorrect link ! </a>
  • 10. ATTRIBUTESELECTORS Match elements that have a certain attribute with an exact value : <p class="error">Oups, this page is not available !</p> Html tag (element) Attribute Content attribute-name="attribute-value" = End of html tag p[class="error"]{ color: purple; } Select all p elements that have a class attribute with exactly the value ‘error’ and make their text color purple. <a href="https://example.com" title="Example Home Page" > Website (with title) </a> a[href="https://example.com"][title="Example Home Page"]{ color: green; } CASE SENSITIVE SELECTOR <a href="https://new-site.com" title="New Site Page" > New Website (with title) </a> <a href="https://my-site.org" > Website (without title) </a> <a title="This is not a link" > Incorrect link ! </a> Select any html hyperlink that has an href attribute with exactly the value ‘https://example.com’ and a title attribute with exactly the value ‘Example Home Page’ and make their text color green.
  • 11. ATTRIBUTESELECTORS Matching one word in a space-separated list (~) : CASE SENSITIVE SELECTOR <p class="alert urgent info" > The is an information message! </p> <p class="alert urgent warning" > The resource took too long to load! </p> <p class="alert urgent error" > The service is unavailable at the moment </p> p[class~="alert"] { color: purple; font-weight: bold; font-size: 18px; } p[class~="warning"] { color: orange; font-size: 12px; } p[class~="error"] { color: red; } Select all p elements whose class attribute contains the word ‘alert’. Select all p elements whose class attribute contains the word ‘warning’. Select all p elements whose class attribute contains the word ‘error’. a[title~="Nasa"] { color: green; font-weight: light; font-size: 15px; } <a href="https://www.nasa.gov/missions" title="Nasa Missions Page" > Nasa Missions Page </a> <a href="https://www.nasa.gov/" title="Nasa Home Page" > Nasa Home Page </a> <a href="https://www.spacex.com/" title="Space X Home Page" > Space X Home Page </a> Space separated list Space separated list Space separated list title="Nasa Missions Page" title="NasaMissions Page" title="Nasa-Missions Page" THE ORDER OF SELECTORS MATTER ! The word only matches inside a space-separated list (case sensitive). title="nasa Missions Page"
  • 12. ATTRIBUTESELECTORS Matching a substring within an attribute value (*) : CASE SENSITIVE SELECTOR THE ORDER OF SELECTORS MATTER ! <h4 class="article-details article-title"> 1914 translation by H. Rackham </h4> <p class="article-details article-description"> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </p> <img class="article-image" alt="mission" src="https://science.nasa.gov/files/science-pink/s3fs-public/styles/ large/public/thumbnails/image/ACE_0.jpg?itok=t2wtXFRN" /> h4[class*="details"] { color: blue; font-weight: bold; font-size: 25px; } p[class*="details"] { color: darkgray; font-weight: light; font-size: 15px; } *[class*="details"] { text-decoration: underline; } *[class*="image"] { width: 10rem; height: 10rem; } Select all h4 elements whose class attribute contains the substring ‘details’. Select all p elements whose class attribute contains the substring ‘details’. Select all elements whose class attribute contains the substring ‘details’. Select all elements whose class attribute contains the substring ‘image’. h4[class~="details"] { color: blue; font-weight: bold; font-size: 25px; } ~ doesn’t much substring but one word in a space-separated list. input[title*="format"] { background-color: red; } <input type="tel" title="Telephone number should be formatted as XXX-XXX-XXXX" pattern="d{3}-d{3}-d{4}" /> <input type="email" title="Email is a mandatory field" required /> img[class*="image"][alt*="details"] { width: 20rem; height: 20rem; } img[class~="article-image"][alt*="details"] { width: 20rem; height: 20rem; } Combining selectors
  • 13. ATTRIBUTESELECTORS Matching a substring at the beginning of an attribute value (^) : CASE SENSITIVE SELECTOR <img class="article-details article-image" alt="ps5-console" src="https://pbs.twimg.com/media/EiGQrbFXsAAzrpq?format=jpg&name=small" /> <img class="article-details article-image" alt="xbox-activision" src="https://image.jeuxvideo.com/medias-md/164253/1642526486-8301-card.jpg" /> <img class="article-details article-image" alt="xbox-serie-x" src="https://static.actu.fr/uploads/2019/04/8c976cba-12d8-42ca-b419-c177f84b66bf.jpg" /> <img class="article-details article-image" alt="kindle-paperwhite" src="https://img.20mn.fr/zBDkMRUzTDerDDNSZYSbWSk/648x415" /> img[alt^="xbox"] { width: 30rem; height: 30rem; border: 2px solid red; } Selecting all img elements whose alt attribute starts with ‘xbox’. <img class="article-details article-image" alt="xbox-activision game" src="https://image.jeuxvideo.com/medias-md/164253/1642526486-8301-card.jpg" /> <img class="article-details article-image" alt="game xbox-serie-x" src="https://static.actu.fr/uploads/2019/04/8c976cba-12d8-42ca-b419-c177f84b66bf.jpg" /> *[class^="alert"] { border: 2px solid red; } <span class="alert error"> This will match the selector </span> <span class="error alert"> This will not match the selector </span> <p class="alert"> This will match the selector </p> <span class="alerterror"> This will match the selector </span> <span class="alert-error"> This will match the selector </span> <p class="Alert"> This will match the selector </p>
  • 14. ATTRIBUTESELECTORS Matching a substring at the end of an attribute value ($) : CASE SENSITIVE SELECTOR <img alt="X-ray glow" src="https://www.sciencenews.org/wp-content/uploads/2022/01/012022_LK_COW_feat-1030x580.jpg" /> <img alt="Neutron star collisions" src=« https://www.sciencenews.org/wp-content/uploads/2021/11/110221_ec_heavy-elements_feat-1030x580.gif" /> <img alt="Intense drought or flash floods" src="https://www.sciencenews.org/wp-content/uploads/2022/01/011421_CG_flooding_feat-1030x580.png" /> <img alt="The first magnetar flare" src="https://www.sciencenews.org/wp-content/uploads/2021/01/011421_lg_magnetar_feat-1030x580.jpg" /> img[src$=".jpg"] { width: 10rem; height: 10rem; border: 2px solid red; } img[src$=".png"] { width: 15rem; height: 15rem; border: 2px solid yellow; } a[href$=".pdf"] { border: 2px solid purple; } <a href="https://cfm.ehu.es/ricardo/docs/python/Learning_Python.pdf" title="Learning Python" > Learning Python </a> <a href="https://cfm.ehu.es/ricardo/docs/python/Learning_Python.PDF" title="Learning Python" > Learning Python </a> <a href="https://cfm.ehu.es/ricardo/docs/python/Learning_Python.csv" title="Learning Python" > Learning Python Stats </a>
  • 15. ATTRIBUTESELECTORS Case insensitive identi fi er (i) : a[href$=".pdf" i] { border: 2px solid purple; } <a href="https://cfm.ehu.es/ricardo/docs/python/Learning_Python.pdf" title="Learning Python" > Learning Python </a> <a href="https://cfm.ehu.es/ricardo/docs/python/Learning_Python.PDF" title="Learning Python" > Learning Python </a> a[title~="Nasa" i] { color: green; font-weight: light; font-size: 15px; } <a href="https://www.nasa.gov/" title="Nasa Home Page" > Nasa Home Page </a> <a href="https://www.nasa.gov/missions" title="nasa Misions Page" > Nasa Misions Page </a> input[title*="format" i] { background-color: red; } <input type="tel" title="Phone number should be formatted as XXX-XXX-XXXX" pattern="d{3}-d{3}-d{4}" /> <input type="tel" title="phone number should be Formatted as XXX-XXX-XXXX" pattern="d{3}-d{3}-d{4}" />
  • 16. ATTRIBUTESELECTORS(RECAP) [my-attribute="attribute-value"] Select any element with an attribute 'my-attribute' whose value is exactly equal to ‘attribute-value'. [my-attribute~="attribute-value"] Select any element with an attribute ‘my-attribute’ whose value contains the word ‘attribute-value’ in a space-separated list of words. [my-attribute*="attribute-value"] Select any element with an attribute 'my-attribute' whose value contains the substring ‘attribute- value'. [my-attribute^="attribute-value"] Select any element with an attribute 'my-attribute' whose value begins with ‘attribute-value'. [my-attribute$="attribute-value"] Select any element with an attribute 'my-attribute' whose value end with ‘attribute-value'. [my-attribute="attribute-value" i] Case insensitive identi fi er (i)
  • 17. DESCENDANTCOMBINATOR selector1 selector2 { property: value; } div span { color: red; } Set the text color to red for any span element descending from div <div> <h4> 1914 translation by H. Rackham </h4> <span> 1. This will match </span> <span> <span> 2. This will match </span> </span> </div> <div> <p> <span>3.This will match</span> </p> </div> .article-details span { color: red; } Selector can be class names <div className="article-details"> <span> <span> 1. This will match </span> </span> <p> <span> <span> 2. This will match </span> </span> </p> </div>
  • 18. CHILDCOMBINATOR selector1 > selector2 { property: value; } div > span { color: red; } Set the text color to red for any span element descending from div <div> <h4> 1914 translation by H. Rackham </h4> <span> 1. This will match </span> <span> <span> 2. This will match </span> </span> </div> <div> <p> <span>3.This will not match</span> </p> </div> ( stricter than the descendant combinator ) Elements matched by the second selector must be the immediate children of the elements matched by the fi rst selector : .article-details > span { color: red; } Selector can be class names <div> <h4> 1914 translation by H. Rackham </h4> <span> 1. This will not match </span> <div className="article-details"> <span> <span> 2. This will match </span> </span> </div> </div> <div> <p> <span>3.This will not match</span> </p> </div>
  • 19. ADJACENTSIBLINGCOMBINATOR former_element + target_element { property: value; } Select an element that immediately follows another element with the same parent : h1 + p { margin-top: 0; } Remove the top margin from a paragraph immediately following an h1 . Select any p element that immediately follows an h1 element that shares a parent with the p element. <div> <h1> 1914 translation by H. Rackham </h1> <p> This paragraph will match </p> <p> This will not match </p> </div> This p isn’t immediately after h1.
  • 20. GENERALSIBLINGCOMBINATOR former_element ~ target_element { property: value; } Select an element that follows another element when both elements share the same parent : h2 ~ ol { font-style: italic; } The two elements do not need to be adjacent sibling. Italicize any ol element that follows an h2 element and also share a parent with h2. <div> <h2> 1914 translation by H. Rackham </h2> <p> Contrary to popular belief, Lorem Ipsum is not simply random text. </p> <ol> <li>1. This will match</li> <li>2. This will match</li> <li>3. This will match</li> </ol> <p> Contrary to popular belief, Lorem Ipsum is not simply random text. </p> <ol> <li>4. This will match</li> <li>5. This will match</li> <li>6. This will match</li> </ol> <div> <ol> <li>1. This will not match</li> <li>2. This will not match</li> <li>3. This will not match</li> </ol> </div> </div> Follows h2 + shares the same parent Follows h2 + shares the same parent Follows h2 but doesn’t shares the same parent
  • 21. SELECTINGEMPTYELEMENTS element:empty { property: value; } Select any element that has no children of any kind, including text nodes (text and whitespace) : <div> <p></p> <p> </p> <p> </p> <p><!--This is a comment--></p> </div> This will match This will not match (white space) This will not match This will match (comments are not considered content). *: empty { display:none;} can hide elements like input, img, text area, because they don’t have children. p:empty { display: none; }
  • 22. SELECTINGUNIQUECHILDREN Select elements when they are the only child element of another element : element:only-child { property: value; } img:only-child { border: 1px solid red; } <a href="http://w3.org/"> <img src="w3.png" alt="W3C" /> </a> <a href="http://w3.org/"> <img src="w3.png" alt="W3C" /> <em>The W3C</em> </a> This will match : img is the only child of a. This will not match : img isn’t the only child of a. Select img that are the only child. <ol> <li> First <ul> <li>This list has just one element.</li> </ul> </li> <li> Second <ul> <li>This list has three elements.</li> <li>This list has three elements.</li> <li>This list has three elements.</li> </ul> </li> </ol> li:only-child { color: red; list-style-type: square; }
  • 23. SELECTINGFIRSTCHILDREN Select elements that are the fi rst children of others elements : element: fi rst-child { property: value; } <div> <p>This text is selected!</p> <p>This text isn't selected.</p> </div> <div> <h2>This text isn't selected: it's not a `p`.</h2> <p>This text isn't selected.</p> </div> p:first-child { color: lime; background-color: black; padding: 5px; } ul li:first-child { color: red; font-weight: bold; } <ul> <li>Item 1</li> <li>Item 2</li> <li> Item 3 <ul> <li>Item 3.1</li> <li>Item 3.2</li> <li>Item 3.3</li> </ul> </li> </ul>
  • 24. SELECTINGLASTCHILDREN Select elements that are the last children of others elements : element:last-child { property: value; } <div> <p>This text isn't selected.</p> <p>This text is selected!</p> </div> <div> <p>This text isn't selected.</p> <h2>This text isn't selected: it's not a `p`.</h2> </div> p:last-child { color: lime; background-color: black; padding: 5px; } <ul> <li>Item 1</li> <li>Item 2</li> <li> Item 3 <ul> <li>Item 3.1</li> <li>Item 3.2</li> <li>Item 3.3</li> </ul> </li> </ul> ul li:last-child { border: 1px solid red; color: red; }
  • 25. SELECTINGEVERYnthCHILDREN Select elements based on their position among a group of siblings : element:nth-child(number) { property: value; } element:nth-child(odd) { property: value; } element:nth-child(even) { property: value; } element:nth-child(a * n + b) { property: value; } element:nth-last-child(number) { property: value; } element:nth-last-child(odd) { property: value; } element:nth-last-child(even) { property: value; } element:nth-last-child(a * n + b) { property: value; } Count start from top to bottom Count start from bottom to top n starts from 0 n starts from 0
  • 26. NEGATIONPSEUDO-CLASS element:not(selector) { property: value; } .moreinfo:not(li) { font-style: italic; } Select all elements with a class whose value contains the word ‘moreinfo’ as long as they are not li elements p:not(:not(p)) Cannot be nested *.article-link:not(li):not(p){ color: red; } Select all elements with class ‘article-link’ that are neither list items nor paragraphs.
  • 27. HYPERLINKPSEUDO-CLASSES :link Matches links that have not yet been visited. :visited Matches links that have been visited. a:link{ color: blue; } a:visited{ color: red; } a.article-details-link:link, a[href^="http"]:link { color: slateblue; } a.article-details-link:visited, a[href^="http"]:visited { color: maroon; } a#article-link-id:link { color: yellow; } a#article-link-id:visited { color: gray; } Class name selectors Element ID selectors
  • 28. USERACTIONPSEUDO-CLASSES :hover Matches when an element is hovered. :active Matches when an item is being activated by the user, for example clicked on. :focus Matches when an element has focus.
  • 29. UI-STATEPSEUDO-CLASSES :enabled Represents a user interface element that is in an enabled state. :disabled Represents a user interface element that is in a disabled state. :read-only Represents any element that cannot be changed by the user. :read-write Represents any element that is user-editable. :checked Matches when elements such as checkboxes and radiobuttons are toggled on. :indeterminate Matches when UI elements are in an indeterminate state. :default Matches one or more UI elements that are the default among a set of elements. :valid Matches an element with valid contents. :invalid Matches an element with invalid contents. :in-range Applies to elements with range limitations, for example a slider control, when the selected value is in the allowed range. :out-of-range Applies to elements with range limitations, for example a slider control, when the selected value is outside the allowed range. :required Matches when a form element is required. :optional Matches when a form element is optional.
  • 30. BEFORE&AFTERPSEUDOELEMENTSSELECTORS ::before Inserts something before the content of each selected element(s). p::before { content: "Read this: "; } ::after Inserts something after the content of each selected element(s). p::after { content: " - Remember this"; }