CSS (Cascading Style Sheet) 8
CSS (Cascading Style Sheet) 8
(CASCADING
STYLE SHEET)
SAQIB SARWAR
by Techsol Media JLT Dubai
CSS (VERSION HISTORY)
CSS comes in different version
CSS1 1996
CSS2 1998
CSS3 2011
WHY LEARN CSS
HTML used for build structure
but
CSS used to do modification and
styles on HTML elements
Responsive Website
Animation on Websites
2D and 3D transformation of HTML
Website development process fast
HTML VS CSS
CSS IMPLEMENTATION WAY
There are 3 Ways to Implement CSS
• Inline Style
• Internal / Inpage Style Tag
• External Style Sheet
INLINE STYLE
We Implement Inline Style sheet by attribute
<article>
<h1 style=“color:red;font-size:15”> </h1>
<p>abcdef…..</p>
</article>
• If 100 article so we have to write color red 100 times
so inline approach fails here.
• And if you need responsiveness, inline not recommended way
INTERNAL /INPAGE STYLE TAG
<head>
<style></style>
</head>
• By Tag Name
<style>
h1{
color:red;
font-size:15px;
}
</style>
INTERNAL /INPAGE STYLE TAG
<head>
<style></style>
</head>
h1{
color:red;
font-size:15px;
}
</style>
UNIVERSAL
Selector Targets Element / Select the Element
• Universal Selector
<style>
*{
color:red;
font-size:15px;
}
</style>
ID
• id
<style>
# paragraph{
color:red;
font-size:15px;
}
</style>
<body>
<p id=“paragraph”>
</body>
CLASS
• Class
<style>
.paragraph{
color:red;
font-size:15px;
}
</style>
<body>
<p class=“paragraph”>
</body>
ADVANCE SELECTOR
Descendant Selector
.mydiv .more-innerdiv
{
color: red;
}
ADVANCE SELECTOR
div + p{
color: blue;
}
ADVANCE SELECTOR
div ~ p{
color: blue;
}
https://flukeout.github.io/
ADVANCE SELECTOR
Attribute Selector
ADVANCE SELECTOR
Img[title]{
Border:2px solid green;
}
ADVANCE SELECTOR
Input[type=‘text’]{
Border: 3px solid Orange;
}
Input[type=‘password’]{
Border: 3px solid Pink;
ADVANCE SELECTOR
img[title^=‘Pakistan’s’]
{
Border: 3px solid Orange;
ADVANCE SELECTOR
-
<Img src=“flower.png” title=“Pakistan’s Flower” />
img[title |=‘Pakistan’s’]{
Border: 3px solid Orange;
ADVANCE SELECTOR
<a href=“images\flower.jpg”>
a[href $=‘.jpg’]
{
border:3px solid green;
}
ADVANCE SELECTOR
<a href=“images\flower.jpg”>
a[href $=‘.jpg’]
{
border:3px solid green;
ADVANCE SELECTOR
<a href=“images\flower.jpg”>
img[title ~=‘of’]
{
Border: 3px solid Orange;
CSS SELECTORS CATEGORY:
Simple Selectors
Combinators Selectors
Attribute Selector
Pseudo Classes & Pseudo elements
PSEUDO CLASSES :
• : first child • : not()
• :last child • :lang()
• :nth-child() • :link
• :nth-last-child() • :hover //must declare after visited in CSS
• :nth-last-of-type() • :visited
• :nth-of-type() • :active
• :only-child • :checked
• :only-of-type • :disabled
• :first-of-type • :enabled
• :last-of-type • : required
• :empty • :root