SlideShare a Scribd company logo
Concept of Web Page
Cascading Style Sheets
Khem Puthea
putheakhemdeveloper@gmail.com
facebook.com/putheaengineer
Khem Puthea
Introducing CSS
៚ CSS works by allowing to associate rules with the elements that appear in a
web page.
៙ These rules govern how the content of those elements should be rendered.
៙ The rule is made up of two parts:
ៜ The selector, which indicates which element or elements the
declaration applies to
ៜ The declaration, which sets out how the elements referred to in the
selector should be styled
៚ e.g.
៙ table {width: 36px;}
ៜ Applies to all the table: <table width="36">
៙ h1, h2, h3 {color: #000000;}
2Khem Puthea
Adding CSS Rules
៚ CSS rules can appear in 3:
៙ A separate file (external style sheet)
ៜ The <link> inside the <head>
ៜ e.g. <link rel="stylesheet" type="text/css"
href="style.css" />
៕ style.css
h1 {color: red;}
៙ The <style> inside the <head>
ៜ e.g.
<style>
h1 {color: red;}
</style>
(internal style sheet)
៙ The style attribute (inline style sheet)
ៜ e.g. <h1 style="color: red;"></h1>
3Khem Puthea
The <link> Element
៚ The <link> is used in web pages to describe the relationship between two
documents.
៙ Carries the core attributes and also: charset dir href hreflang
media rel rev style target type
៚ The rel is required and specifies the relationship between the documents;
e.g. rel="stylesheet".
៚ The type specifies the MIME type the document begin linked to; e.g.
type="text/css".
៚ The href indicates where to find the file via URL.
៚ The media specifies the output device that is intended for use with the
document.
៙ media="screen | tty | tv | print | projection |
handheld | braille | embossed | aural | all"
4Khem Puthea
The <style> Element
៚ The <style> inside the <head> contains style sheet rules within a page.
៙ A single page needs to contain just a few extra rules that do not apply to
the others.
៙ Carries: dir lang media title type
៚ Advantages of External CSS Style Sheet:
៙ Save repeating the same style
៙ Be easier to update
៙ Be quicker to load
៙ Act as a style template
៙ Different style sheets can be attached.
៙ Can import and use styles from other style sheets
5Khem Puthea
Controlling Text
៚ A typeface is a family of fonts, such as the Arial family.
៚ A font is a specific member of that family, such as Arial 12-point bold.
6
Property Purpose
font Combine several following properties into one
font-family The typeface or family
font-size The size
font-weight Normal or bold
font-style Normal, italic or oblique
font-stretch The width of the actual characters
font-variant Normal or small caps
font-size-adjust The aspect ratio of the size
Khem Puthea
Controlling Text (cont.)
៚ The font-family
៙ e.g. h1 {font-family: arial, verdana, "courier new";}
៚ The font-size
៙ Units of length: px em ex pt in cm pc mm
ៜ e.g. h1 {font-size: 36px;}
៙ Absolute size: xx-small x-small
xx-large
៙ Relative size: smaller larger
៙ Percentage
៚ The font-weight
៙ The values: normal bold bolder
៚ The font-style
small medium large x-large
lighter 100 200 ... 900
៙ The values: normal italic oblique
៚ The font-variant
៙ Smaller version of the uppercases.
៙ The values: normal small-caps
7Khem Puthea
Text Formatting
8
Property Purpose
color The color
text-align The horizontal alignment of the text within the container
vertical-align The vertical alignment
font-decoration Underlined, overlined, strikethrough or blinking
font-indent An indent from the left border
font-transform Uppercase, lowercase or capitalized
text-shadow A drop shadow
letter-spacing The space between the letters
word-spacing The spacing between the words
white-space Collapsed, preserved or prevented from wrapping
direction The direction
Khem Puthea
Text Formatting (cont.)
៚ The color
៙ e.g. h1 {color: #0000FF;}
៚ The text-align
៙ The values: left right center justify
៚ The vertical-align
៙ The values: baseline sub super top text-top
text-bottom
៚ The text-decoration
៙ The values: underline overline line-through
៚ The text-indent
៙ e.g. h1 {text-indent: 9px;}
៚ The text-shadow
middle bottom
blink
៙ The 4 values respective: color X-length Y-length blur-length
៙ e.g. h1 {text-shadow: #0000FF 10px 10px 6px;}
9Khem Puthea
Text Formatting (cont.)
៚ The text-transform
៙ The values: none capitalize uppercase
៚ The white-space
៙ The values: normal pre nowrap
៚ The direction
lowercase
៙ The values: ltr rtl inherit
10Khem Puthea
Text Pseudo-Classes
៚ The first-letter
៙ Allows to specify a rule just for the first letter
៚ The first-line
៙ Allows to specify a rule just for the first line
៚ e.g. textPseudo-classes.html
...
<style>
p.first:first-letter {font-size: 36px}
p.first:first-line {font-style:
</style>
...
<p class="first">
oblique}
A is an apple.<br
B is a banana.
</p>
...
/>
11Khem Puthea
Selectors
៚ Universal Selector
៙ A wildcard and matches all elements
៙ e.g. * {font-size: 10px;}
៚ The Type Selector
៙ Matches all elements specified in the comma-delimited list
៙ e.g. h1, h2 {color: red;}
៚ The Class Selector
៙ Matches an element or elements carrying a class attribute whose value
matches in the class selector
៙ e.g.
ៜ HTML: <p class="red">I am red.</p>
ៜ CSS
៕ Specific selector: p.red {color: red;}
៕ Share selector: .red {color: red;}
12Khem Puthea
Selectors (cont.)
៙ A class can also contain several values separated by a space.
៙ e.g.
ៜ HTML: <p class="bold red">I am bold
ៜ CSS: p.bold.red {color: red;}
៚ The ID Selector
៙ Matches one element via the value of id attribute
៙ e.g.
ៜ HTML: <p id="red">I am red.</p>
ៜ CSS: p.#red {color: red;}
៚ The Child Selector
៙ Matches an element that is a direct child of another
៙ e.g.
ៜ The <i> is the direct child of the <b>.
ៜ HTML: <b><i>I am red.</i></b>
ៜ CSS: b > i {color: red;}
red.</p>
13Khem Puthea
Selectors (cont.)
៚ The Descendant Selector
៙ Matches an element that is a descendant of another
៙ e.g.
ៜ The <i> is the descendant of the <p>.
ៜ HTML: <p><b><i>I am red.</i></b></p>
ៜ CSS: p i {color: red;}
៚ The Adjacent Sibling Selector
៙ Matches an element that is a next sibling of another
៙ e.g.
ៜ The <p> is the next sibling of the <h1>.
ៜ HTML: <h1></h1><p>I am red.</p>
ៜ h1 + p {color: red;}
៚ The General Sibling Selector
៙ Matches an element that is a sibling of another
៙ e.g.
ៜ The <p> is the next sibling of the <h1>.
ៜ HTML: <h1></h1><b></b><p>I am red.</p>
ៜ h1 - p {color: red;}
14Khem Puthea
Selectors (cont.)
៚ e.g. selectors.html
<style>
p {font-family:"Courier New", Courier, monospace;}
div > p {background-color:
p + p {color: red;}
</style>
...
<div>
#C3C3C3;}
<p>A
<p>B
<p>C
</div>
...
is
is
is
an apple.</p>
a
a
banana.</p>
coconut.</p>
15Khem Puthea
Attribute Selectors
HTML: <p class="short red"></p>
HTML: <p language="en-US"></p>
Any attribute whose value begins with "b".
Any attribute whose value contains "b".
Any attribute whose value end with "b".
16
Name Example
Existence p[id]
Equality p[id="short"]
Space
p[class-="short"]
Hyphen
p[language|="en"]
Prefix (CSS3)
p[attr^"b"]
Substring (CSS3)
p[attr*"b"]
Suffix (CSS3)
p[attr$"b"]
Khem Puthea
Lengths
៚ Relative Units
៙ px (pixel)
៙ em (the height of the current font of a lowercase m)
៙ ex (the height of a lowercase x)
៚ Absolute Units
៙ pt (point)
៙ pc (pica)
៙ in (inch)
៙ cm
៙ mm
៚ Percentages
៙ Give a value in relation to another value.
17Khem Puthea
Introducing the Box Model
Separates the edge of one box from other surrounding boxes
18
Property Description
border
3 parameters: color style width
margin The distance between the border of a box and the box next to it
padding The space between the content of the box and its border
Khem Puthea
Introducing the Box Model (cont.)
៚ e.g. introducingBoxModel.html
...
<style>
p {
border-style: solid;
padding: 20px;
margin: 10px;
padding-left: 0px;
}
b {border-style: solid;}
</style>
...
<p>A
<p>B
<p>C
...
is
is
is
an <b>apple</b>.</p>
a banana.</p>
a coconut.</p>
19Khem Puthea
Introducing the Box Model (cont.)
៚ The Border Properties
៙ border-color
៙ border-style
ៜ The values: none solid dotted dashed double
ridge inset outset hidden
៙ border-width
groove
ៜ The values: in absolute unit or relative one: thin medium thick
៚ The border properties are individual; i.e. border-top-color border-
bottom-color border-left-color border-right-color ...
20
Color hex RGB Values RGB %
red #FF0000 rgb(255, 0, 0) rgb(100%, 0, 0)
green #00FF00 rgb(0, 255, 0) rgb(0, 100%, 0)
blue #0000FF rgb(0, 0, 255) rgb(0, 0, 100%)
Khem Puthea
Introducing the Box Model (cont.)
៚ The Dimensions of a Box
៙ height
៙ width
៙ line-height
ៜ The space between lines of text
៙ max-height
៙ min-height
៙ max-width
៙ min-width
៙ overflow
ៜ Controls the visualization of the content in the box
ៜ The values: hidden scroll
21Khem Puthea

More Related Content

What's hot (19)

Web Design Course: CSS lecture 4
Web Design Course: CSS  lecture 4Web Design Course: CSS  lecture 4
Web Design Course: CSS lecture 4
Gheyath M. Othman
 
Web Design Course: CSS lecture 2
Web Design Course: CSS  lecture 2Web Design Course: CSS  lecture 2
Web Design Course: CSS lecture 2
Gheyath M. Othman
 
Css lecture notes
Css lecture notesCss lecture notes
Css lecture notes
Santhiya Grace
 
Concept of CSS unit3
Concept of CSS unit3Concept of CSS unit3
Concept of CSS unit3
Dr. SURBHI SAROHA
 
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
 
Html 2
Html   2Html   2
Html 2
pavishkumarsingh
 
CSS Refresher
CSS RefresherCSS Refresher
CSS Refresher
Gerson Abesamis
 
Cascading Style Sheets By Mukesh
Cascading Style Sheets By MukeshCascading Style Sheets By Mukesh
Cascading Style Sheets By Mukesh
Mukesh Kumar
 
Cascstylesheets
CascstylesheetsCascstylesheets
Cascstylesheets
Digital Insights - Digital Marketing Agency
 
CSS for Beginners
CSS for BeginnersCSS for Beginners
CSS for Beginners
Amit Kumar Singh
 
Css1
Css1Css1
Css1
Vadim Spiridenko
 
Pemrograman Web 3 - CSS Basic Part 2
Pemrograman Web 3 - CSS Basic Part 2Pemrograman Web 3 - CSS Basic Part 2
Pemrograman Web 3 - CSS Basic Part 2
Nur Fadli Utomo
 
Css3 Complete Reference
Css3 Complete ReferenceCss3 Complete Reference
Css3 Complete Reference
EPAM Systems
 
LIS3353 SP12 Week 13
LIS3353 SP12 Week 13LIS3353 SP12 Week 13
LIS3353 SP12 Week 13
Amanda Case
 
Web Design Course: CSS lecture 5
Web Design Course: CSS  lecture 5Web Design Course: CSS  lecture 5
Web Design Course: CSS lecture 5
Gheyath M. Othman
 
Css presentation introdution with sample basic projects
Css presentation introdution with sample basic projectsCss presentation introdution with sample basic projects
Css presentation introdution with sample basic projects
Digital Shende
 
HTML CSS Basics
HTML CSS BasicsHTML CSS Basics
HTML CSS Basics
Mai Moustafa
 
Css1
Css1Css1
Css1
Vadim Spiridenko
 
Html
HtmlHtml
Html
NithyaD5
 

Similar to Introduction to css part1 (20)

CSCADING style sheet. Internal external inline
CSCADING style sheet. Internal external inlineCSCADING style sheet. Internal external inline
CSCADING style sheet. Internal external inline
Ranjeet Reddy
 
css-ppt.pdf
css-ppt.pdfcss-ppt.pdf
css-ppt.pdf
EktaDesai14
 
Cascading Style Sheet
Cascading Style SheetCascading Style Sheet
Cascading Style Sheet
KushagraChadha1
 
Css tutorial by [email protected]
Css tutorial by viveksingh698@gmail.comCss tutorial by viveksingh698@gmail.com
Css tutorial by [email protected]
vivek698
 
Css tutorial
Css tutorial Css tutorial
Css tutorial
Fakhrul Islam Talukder
 
Css tutorial
Css tutorialCss tutorial
Css tutorial
Edress Oryakhail
 
Css tutorial
Css tutorialCss tutorial
Css tutorial
Mohamed Idris
 
html
htmlhtml
html
MeKwang Kreng
 
Css
CssCss
Css
Abhishek Kesharwani
 
ch-hguygureehuvnvdfduyertiuhrnhduuyfjh3.pdf
ch-hguygureehuvnvdfduyertiuhrnhduuyfjh3.pdfch-hguygureehuvnvdfduyertiuhrnhduuyfjh3.pdf
ch-hguygureehuvnvdfduyertiuhrnhduuyfjh3.pdf
kasutaye192
 
CSS
CSSCSS
CSS
DivyaKS12
 
CSS Training in Bangalore
CSS Training in BangaloreCSS Training in Bangalore
CSS Training in Bangalore
rajkamal560066
 
Cascading Style Sheets
Cascading Style SheetsCascading Style Sheets
Cascading Style Sheets
Mukesh Tekwani
 
3. CSS
3. CSS3. CSS
3. CSS
Pavle Đorđević
 
cdocumentsandsettingsstudentdesktopnewfolderhtmlcss-100220030010-phpapp01.pdf
cdocumentsandsettingsstudentdesktopnewfolderhtmlcss-100220030010-phpapp01.pdfcdocumentsandsettingsstudentdesktopnewfolderhtmlcss-100220030010-phpapp01.pdf
cdocumentsandsettingsstudentdesktopnewfolderhtmlcss-100220030010-phpapp01.pdf
hinalsomani93
 
IP - Lecture 6, 7 Chapter-3 (3).ppt
IP - Lecture 6, 7 Chapter-3 (3).pptIP - Lecture 6, 7 Chapter-3 (3).ppt
IP - Lecture 6, 7 Chapter-3 (3).ppt
kassahungebrie
 
Css tutorial
Css tutorialCss tutorial
Css tutorial
Sohail Christoper
 
Css - Tutorial
Css - TutorialCss - Tutorial
Css - Tutorial
adelaticleanu
 
Cascading Styling Sheets(CSS) simple design language intended to transform th...
Cascading Styling Sheets(CSS) simple design language intended to transform th...Cascading Styling Sheets(CSS) simple design language intended to transform th...
Cascading Styling Sheets(CSS) simple design language intended to transform th...
JebaRaj26
 
CSS
CSSCSS
CSS
Raja Kumar Ranjan
 
Ad

Recently uploaded (20)

How to Manage Multi Language for Invoice in Odoo 18
How to Manage Multi Language for Invoice in Odoo 18How to Manage Multi Language for Invoice in Odoo 18
How to Manage Multi Language for Invoice in Odoo 18
Celine George
 
Allomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdfAllomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdf
Abha Pandey
 
IDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptxIDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptx
ArneeAgligar
 
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
parmarjuli1412
 
Revista digital preescolar en transformación
Revista digital preescolar en transformaciónRevista digital preescolar en transformación
Revista digital preescolar en transformación
guerragallardo26
 
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKANMATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
LDMMIA GRAD Student Check-in Orientation Sampler
LDMMIA GRAD Student Check-in Orientation SamplerLDMMIA GRAD Student Check-in Orientation Sampler
LDMMIA GRAD Student Check-in Orientation Sampler
LDM & Mia eStudios
 
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptxSPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
Sourav Kr Podder
 
ABCs of Bookkeeping for Nonprofits TechSoup.pdf
ABCs of Bookkeeping for Nonprofits TechSoup.pdfABCs of Bookkeeping for Nonprofits TechSoup.pdf
ABCs of Bookkeeping for Nonprofits TechSoup.pdf
TechSoup
 
The Man In The Back – Exceptional Delaware.pdf
The Man In The Back – Exceptional Delaware.pdfThe Man In The Back – Exceptional Delaware.pdf
The Man In The Back – Exceptional Delaware.pdf
dennisongomezk
 
BINARY files CSV files JSON files with example.pptx
BINARY files CSV files JSON files with example.pptxBINARY files CSV files JSON files with example.pptx
BINARY files CSV files JSON files with example.pptx
Ramakrishna Reddy Bijjam
 
Unit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptxUnit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptx
bobby205207
 
What is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptxWhat is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptx
Ramakrishna Reddy Bijjam
 
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptxPEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
Arshad Shaikh
 
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition IILDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDM & Mia eStudios
 
BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024
BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024
BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024
Quiz Club of PSG College of Arts & Science
 
Final Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptxFinal Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptx
bobby205207
 
Capitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptxCapitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptx
CapitolTechU
 
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptxAnalysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Shrutidhara2
 
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_HyderabadWebcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Veera Pallapu
 
How to Manage Multi Language for Invoice in Odoo 18
How to Manage Multi Language for Invoice in Odoo 18How to Manage Multi Language for Invoice in Odoo 18
How to Manage Multi Language for Invoice in Odoo 18
Celine George
 
Allomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdfAllomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdf
Abha Pandey
 
IDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptxIDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptx
ArneeAgligar
 
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
parmarjuli1412
 
Revista digital preescolar en transformación
Revista digital preescolar en transformaciónRevista digital preescolar en transformación
Revista digital preescolar en transformación
guerragallardo26
 
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKANMATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
LDMMIA GRAD Student Check-in Orientation Sampler
LDMMIA GRAD Student Check-in Orientation SamplerLDMMIA GRAD Student Check-in Orientation Sampler
LDMMIA GRAD Student Check-in Orientation Sampler
LDM & Mia eStudios
 
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptxSPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
Sourav Kr Podder
 
ABCs of Bookkeeping for Nonprofits TechSoup.pdf
ABCs of Bookkeeping for Nonprofits TechSoup.pdfABCs of Bookkeeping for Nonprofits TechSoup.pdf
ABCs of Bookkeeping for Nonprofits TechSoup.pdf
TechSoup
 
The Man In The Back – Exceptional Delaware.pdf
The Man In The Back – Exceptional Delaware.pdfThe Man In The Back – Exceptional Delaware.pdf
The Man In The Back – Exceptional Delaware.pdf
dennisongomezk
 
BINARY files CSV files JSON files with example.pptx
BINARY files CSV files JSON files with example.pptxBINARY files CSV files JSON files with example.pptx
BINARY files CSV files JSON files with example.pptx
Ramakrishna Reddy Bijjam
 
Unit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptxUnit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptx
bobby205207
 
What is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptxWhat is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptx
Ramakrishna Reddy Bijjam
 
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptxPEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
Arshad Shaikh
 
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition IILDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDM & Mia eStudios
 
Final Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptxFinal Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptx
bobby205207
 
Capitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptxCapitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptx
CapitolTechU
 
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptxAnalysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Shrutidhara2
 
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_HyderabadWebcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Veera Pallapu
 
Ad

Introduction to css part1

  • 1. Concept of Web Page Cascading Style Sheets Khem Puthea [email protected] facebook.com/putheaengineer Khem Puthea
  • 2. Introducing CSS ៚ CSS works by allowing to associate rules with the elements that appear in a web page. ៙ These rules govern how the content of those elements should be rendered. ៙ The rule is made up of two parts: ៜ The selector, which indicates which element or elements the declaration applies to ៜ The declaration, which sets out how the elements referred to in the selector should be styled ៚ e.g. ៙ table {width: 36px;} ៜ Applies to all the table: <table width="36"> ៙ h1, h2, h3 {color: #000000;} 2Khem Puthea
  • 3. Adding CSS Rules ៚ CSS rules can appear in 3: ៙ A separate file (external style sheet) ៜ The <link> inside the <head> ៜ e.g. <link rel="stylesheet" type="text/css" href="style.css" /> ៕ style.css h1 {color: red;} ៙ The <style> inside the <head> ៜ e.g. <style> h1 {color: red;} </style> (internal style sheet) ៙ The style attribute (inline style sheet) ៜ e.g. <h1 style="color: red;"></h1> 3Khem Puthea
  • 4. The <link> Element ៚ The <link> is used in web pages to describe the relationship between two documents. ៙ Carries the core attributes and also: charset dir href hreflang media rel rev style target type ៚ The rel is required and specifies the relationship between the documents; e.g. rel="stylesheet". ៚ The type specifies the MIME type the document begin linked to; e.g. type="text/css". ៚ The href indicates where to find the file via URL. ៚ The media specifies the output device that is intended for use with the document. ៙ media="screen | tty | tv | print | projection | handheld | braille | embossed | aural | all" 4Khem Puthea
  • 5. The <style> Element ៚ The <style> inside the <head> contains style sheet rules within a page. ៙ A single page needs to contain just a few extra rules that do not apply to the others. ៙ Carries: dir lang media title type ៚ Advantages of External CSS Style Sheet: ៙ Save repeating the same style ៙ Be easier to update ៙ Be quicker to load ៙ Act as a style template ៙ Different style sheets can be attached. ៙ Can import and use styles from other style sheets 5Khem Puthea
  • 6. Controlling Text ៚ A typeface is a family of fonts, such as the Arial family. ៚ A font is a specific member of that family, such as Arial 12-point bold. 6 Property Purpose font Combine several following properties into one font-family The typeface or family font-size The size font-weight Normal or bold font-style Normal, italic or oblique font-stretch The width of the actual characters font-variant Normal or small caps font-size-adjust The aspect ratio of the size Khem Puthea
  • 7. Controlling Text (cont.) ៚ The font-family ៙ e.g. h1 {font-family: arial, verdana, "courier new";} ៚ The font-size ៙ Units of length: px em ex pt in cm pc mm ៜ e.g. h1 {font-size: 36px;} ៙ Absolute size: xx-small x-small xx-large ៙ Relative size: smaller larger ៙ Percentage ៚ The font-weight ៙ The values: normal bold bolder ៚ The font-style small medium large x-large lighter 100 200 ... 900 ៙ The values: normal italic oblique ៚ The font-variant ៙ Smaller version of the uppercases. ៙ The values: normal small-caps 7Khem Puthea
  • 8. Text Formatting 8 Property Purpose color The color text-align The horizontal alignment of the text within the container vertical-align The vertical alignment font-decoration Underlined, overlined, strikethrough or blinking font-indent An indent from the left border font-transform Uppercase, lowercase or capitalized text-shadow A drop shadow letter-spacing The space between the letters word-spacing The spacing between the words white-space Collapsed, preserved or prevented from wrapping direction The direction Khem Puthea
  • 9. Text Formatting (cont.) ៚ The color ៙ e.g. h1 {color: #0000FF;} ៚ The text-align ៙ The values: left right center justify ៚ The vertical-align ៙ The values: baseline sub super top text-top text-bottom ៚ The text-decoration ៙ The values: underline overline line-through ៚ The text-indent ៙ e.g. h1 {text-indent: 9px;} ៚ The text-shadow middle bottom blink ៙ The 4 values respective: color X-length Y-length blur-length ៙ e.g. h1 {text-shadow: #0000FF 10px 10px 6px;} 9Khem Puthea
  • 10. Text Formatting (cont.) ៚ The text-transform ៙ The values: none capitalize uppercase ៚ The white-space ៙ The values: normal pre nowrap ៚ The direction lowercase ៙ The values: ltr rtl inherit 10Khem Puthea
  • 11. Text Pseudo-Classes ៚ The first-letter ៙ Allows to specify a rule just for the first letter ៚ The first-line ៙ Allows to specify a rule just for the first line ៚ e.g. textPseudo-classes.html ... <style> p.first:first-letter {font-size: 36px} p.first:first-line {font-style: </style> ... <p class="first"> oblique} A is an apple.<br B is a banana. </p> ... /> 11Khem Puthea
  • 12. Selectors ៚ Universal Selector ៙ A wildcard and matches all elements ៙ e.g. * {font-size: 10px;} ៚ The Type Selector ៙ Matches all elements specified in the comma-delimited list ៙ e.g. h1, h2 {color: red;} ៚ The Class Selector ៙ Matches an element or elements carrying a class attribute whose value matches in the class selector ៙ e.g. ៜ HTML: <p class="red">I am red.</p> ៜ CSS ៕ Specific selector: p.red {color: red;} ៕ Share selector: .red {color: red;} 12Khem Puthea
  • 13. Selectors (cont.) ៙ A class can also contain several values separated by a space. ៙ e.g. ៜ HTML: <p class="bold red">I am bold ៜ CSS: p.bold.red {color: red;} ៚ The ID Selector ៙ Matches one element via the value of id attribute ៙ e.g. ៜ HTML: <p id="red">I am red.</p> ៜ CSS: p.#red {color: red;} ៚ The Child Selector ៙ Matches an element that is a direct child of another ៙ e.g. ៜ The <i> is the direct child of the <b>. ៜ HTML: <b><i>I am red.</i></b> ៜ CSS: b > i {color: red;} red.</p> 13Khem Puthea
  • 14. Selectors (cont.) ៚ The Descendant Selector ៙ Matches an element that is a descendant of another ៙ e.g. ៜ The <i> is the descendant of the <p>. ៜ HTML: <p><b><i>I am red.</i></b></p> ៜ CSS: p i {color: red;} ៚ The Adjacent Sibling Selector ៙ Matches an element that is a next sibling of another ៙ e.g. ៜ The <p> is the next sibling of the <h1>. ៜ HTML: <h1></h1><p>I am red.</p> ៜ h1 + p {color: red;} ៚ The General Sibling Selector ៙ Matches an element that is a sibling of another ៙ e.g. ៜ The <p> is the next sibling of the <h1>. ៜ HTML: <h1></h1><b></b><p>I am red.</p> ៜ h1 - p {color: red;} 14Khem Puthea
  • 15. Selectors (cont.) ៚ e.g. selectors.html <style> p {font-family:"Courier New", Courier, monospace;} div > p {background-color: p + p {color: red;} </style> ... <div> #C3C3C3;} <p>A <p>B <p>C </div> ... is is is an apple.</p> a a banana.</p> coconut.</p> 15Khem Puthea
  • 16. Attribute Selectors HTML: <p class="short red"></p> HTML: <p language="en-US"></p> Any attribute whose value begins with "b". Any attribute whose value contains "b". Any attribute whose value end with "b". 16 Name Example Existence p[id] Equality p[id="short"] Space p[class-="short"] Hyphen p[language|="en"] Prefix (CSS3) p[attr^"b"] Substring (CSS3) p[attr*"b"] Suffix (CSS3) p[attr$"b"] Khem Puthea
  • 17. Lengths ៚ Relative Units ៙ px (pixel) ៙ em (the height of the current font of a lowercase m) ៙ ex (the height of a lowercase x) ៚ Absolute Units ៙ pt (point) ៙ pc (pica) ៙ in (inch) ៙ cm ៙ mm ៚ Percentages ៙ Give a value in relation to another value. 17Khem Puthea
  • 18. Introducing the Box Model Separates the edge of one box from other surrounding boxes 18 Property Description border 3 parameters: color style width margin The distance between the border of a box and the box next to it padding The space between the content of the box and its border Khem Puthea
  • 19. Introducing the Box Model (cont.) ៚ e.g. introducingBoxModel.html ... <style> p { border-style: solid; padding: 20px; margin: 10px; padding-left: 0px; } b {border-style: solid;} </style> ... <p>A <p>B <p>C ... is is is an <b>apple</b>.</p> a banana.</p> a coconut.</p> 19Khem Puthea
  • 20. Introducing the Box Model (cont.) ៚ The Border Properties ៙ border-color ៙ border-style ៜ The values: none solid dotted dashed double ridge inset outset hidden ៙ border-width groove ៜ The values: in absolute unit or relative one: thin medium thick ៚ The border properties are individual; i.e. border-top-color border- bottom-color border-left-color border-right-color ... 20 Color hex RGB Values RGB % red #FF0000 rgb(255, 0, 0) rgb(100%, 0, 0) green #00FF00 rgb(0, 255, 0) rgb(0, 100%, 0) blue #0000FF rgb(0, 0, 255) rgb(0, 0, 100%) Khem Puthea
  • 21. Introducing the Box Model (cont.) ៚ The Dimensions of a Box ៙ height ៙ width ៙ line-height ៜ The space between lines of text ៙ max-height ៙ min-height ៙ max-width ៙ min-width ៙ overflow ៜ Controls the visualization of the content in the box ៜ The values: hidden scroll 21Khem Puthea