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)

PDF
Web Design Course: CSS lecture 4
Gheyath M. Othman
 
PDF
Web Design Course: CSS lecture 2
Gheyath M. Othman
 
PPT
Css lecture notes
Santhiya Grace
 
PPTX
Concept of CSS unit3
Dr. SURBHI SAROHA
 
PPT
How Cascading Style Sheets (CSS) Works
Amit Tyagi
 
PPTX
Html 2
pavishkumarsingh
 
PDF
CSS Refresher
Gerson Abesamis
 
PPT
Cascading Style Sheets By Mukesh
Mukesh Kumar
 
PPT
CSS for Beginners
Amit Kumar Singh
 
PDF
Pemrograman Web 3 - CSS Basic Part 2
Nur Fadli Utomo
 
PPTX
Css3 Complete Reference
EPAM Systems
 
PPTX
LIS3353 SP12 Week 13
Amanda Case
 
PDF
Web Design Course: CSS lecture 5
Gheyath M. Othman
 
PDF
Css presentation introdution with sample basic projects
Digital Shende
 
PDF
HTML CSS Basics
Mai Moustafa
 
PPTX
Html
NithyaD5
 
Web Design Course: CSS lecture 4
Gheyath M. Othman
 
Web Design Course: CSS lecture 2
Gheyath M. Othman
 
Css lecture notes
Santhiya Grace
 
Concept of CSS unit3
Dr. SURBHI SAROHA
 
How Cascading Style Sheets (CSS) Works
Amit Tyagi
 
CSS Refresher
Gerson Abesamis
 
Cascading Style Sheets By Mukesh
Mukesh Kumar
 
CSS for Beginners
Amit Kumar Singh
 
Pemrograman Web 3 - CSS Basic Part 2
Nur Fadli Utomo
 
Css3 Complete Reference
EPAM Systems
 
LIS3353 SP12 Week 13
Amanda Case
 
Web Design Course: CSS lecture 5
Gheyath M. Othman
 
Css presentation introdution with sample basic projects
Digital Shende
 
HTML CSS Basics
Mai Moustafa
 
Html
NithyaD5
 

Similar to Introduction to css part1 (20)

PDF
CSCADING style sheet. Internal external inline
Ranjeet Reddy
 
PDF
css-ppt.pdf
EktaDesai14
 
PPTX
Cascading Style Sheet
KushagraChadha1
 
PDF
Css tutorial by [email protected]
vivek698
 
PDF
Css tutorial
Fakhrul Islam Talukder
 
PDF
Css tutorial
Edress Oryakhail
 
PDF
Css tutorial
Mohamed Idris
 
PPTX
html
MeKwang Kreng
 
PDF
ch-hguygureehuvnvdfduyertiuhrnhduuyfjh3.pdf
kasutaye192
 
PPTX
CSS
DivyaKS12
 
PPT
CSS Training in Bangalore
rajkamal560066
 
PDF
Cascading Style Sheets
Mukesh Tekwani
 
PDF
cdocumentsandsettingsstudentdesktopnewfolderhtmlcss-100220030010-phpapp01.pdf
hinalsomani93
 
PPT
IP - Lecture 6, 7 Chapter-3 (3).ppt
kassahungebrie
 
PDF
Css tutorial
Sohail Christoper
 
PDF
Css - Tutorial
adelaticleanu
 
PPTX
Cascading Styling Sheets(CSS) simple design language intended to transform th...
JebaRaj26
 
CSCADING style sheet. Internal external inline
Ranjeet Reddy
 
css-ppt.pdf
EktaDesai14
 
Cascading Style Sheet
KushagraChadha1
 
Css tutorial by [email protected]
vivek698
 
Css tutorial
Fakhrul Islam Talukder
 
Css tutorial
Edress Oryakhail
 
Css tutorial
Mohamed Idris
 
ch-hguygureehuvnvdfduyertiuhrnhduuyfjh3.pdf
kasutaye192
 
CSS Training in Bangalore
rajkamal560066
 
Cascading Style Sheets
Mukesh Tekwani
 
cdocumentsandsettingsstudentdesktopnewfolderhtmlcss-100220030010-phpapp01.pdf
hinalsomani93
 
IP - Lecture 6, 7 Chapter-3 (3).ppt
kassahungebrie
 
Css tutorial
Sohail Christoper
 
Css - Tutorial
adelaticleanu
 
Cascading Styling Sheets(CSS) simple design language intended to transform th...
JebaRaj26
 
Ad

Recently uploaded (20)

PDF
IMPORTANT GUIDELINES FOR M.Sc.ZOOLOGY DISSERTATION
raviralanaresh2
 
PDF
COM and NET Component Services 1st Edition Juval Löwy
kboqcyuw976
 
PDF
Our Guide to the July 2025 USPS® Rate Change
Postal Advocate Inc.
 
PDF
I3PM Case study smart parking 2025 with uptoIP® and ABP
MIPLM
 
PPTX
How to Setup Automatic Reordering Rule in Odoo 18 Inventory
Celine George
 
PPTX
MATH 8 QUARTER 1 WEEK 1 LESSON 2 PRESENTATION
JohnGuillerNestalBah1
 
PDF
Cooperative wireless communications 1st Edition Yan Zhang
jsphyftmkb123
 
PDF
TechSoup Microsoft Copilot Nonprofit Use Cases and Live Demo - 2025.06.25.pdf
TechSoup
 
DOCX
Lesson 1 - Nature and Inquiry of Research
marvinnbustamante1
 
PPTX
PLANNING A HOSPITAL AND NURSING UNIT.pptx
PRADEEP ABOTHU
 
PPTX
How to Configure Refusal of Applicants in Odoo 18 Recruitment
Celine George
 
PPTX
PLANNING FOR EMERGENCY AND DISASTER MANAGEMENT ppt.pptx
PRADEEP ABOTHU
 
PDF
Supply Chain Security A Comprehensive Approach 1st Edition Arthur G. Arway
rxgnika452
 
PPTX
Life and Career Skills Lesson 2.pptxProtective and Risk Factors of Late Adole...
ryangabrielcatalon40
 
PDF
Nanotechnology and Functional Foods Effective Delivery of Bioactive Ingredien...
rmswlwcxai8321
 
PPTX
Parsing HTML read and write operations and OS Module.pptx
Ramakrishna Reddy Bijjam
 
PDF
I3PM Industry Case Study Siemens on Strategic and Value-Oriented IP Management
MIPLM
 
PPTX
How to Create & Manage Stages in Odoo 18 Helpdesk
Celine George
 
PPTX
How to Add a Custom Button in Odoo 18 POS Screen
Celine George
 
PDF
CAD25 Gbadago and Fafa Presentation Revised-Aston Business School, UK.pdf
Kweku Zurek
 
IMPORTANT GUIDELINES FOR M.Sc.ZOOLOGY DISSERTATION
raviralanaresh2
 
COM and NET Component Services 1st Edition Juval Löwy
kboqcyuw976
 
Our Guide to the July 2025 USPS® Rate Change
Postal Advocate Inc.
 
I3PM Case study smart parking 2025 with uptoIP® and ABP
MIPLM
 
How to Setup Automatic Reordering Rule in Odoo 18 Inventory
Celine George
 
MATH 8 QUARTER 1 WEEK 1 LESSON 2 PRESENTATION
JohnGuillerNestalBah1
 
Cooperative wireless communications 1st Edition Yan Zhang
jsphyftmkb123
 
TechSoup Microsoft Copilot Nonprofit Use Cases and Live Demo - 2025.06.25.pdf
TechSoup
 
Lesson 1 - Nature and Inquiry of Research
marvinnbustamante1
 
PLANNING A HOSPITAL AND NURSING UNIT.pptx
PRADEEP ABOTHU
 
How to Configure Refusal of Applicants in Odoo 18 Recruitment
Celine George
 
PLANNING FOR EMERGENCY AND DISASTER MANAGEMENT ppt.pptx
PRADEEP ABOTHU
 
Supply Chain Security A Comprehensive Approach 1st Edition Arthur G. Arway
rxgnika452
 
Life and Career Skills Lesson 2.pptxProtective and Risk Factors of Late Adole...
ryangabrielcatalon40
 
Nanotechnology and Functional Foods Effective Delivery of Bioactive Ingredien...
rmswlwcxai8321
 
Parsing HTML read and write operations and OS Module.pptx
Ramakrishna Reddy Bijjam
 
I3PM Industry Case Study Siemens on Strategic and Value-Oriented IP Management
MIPLM
 
How to Create & Manage Stages in Odoo 18 Helpdesk
Celine George
 
How to Add a Custom Button in Odoo 18 POS Screen
Celine George
 
CAD25 Gbadago and Fafa Presentation Revised-Aston Business School, UK.pdf
Kweku Zurek
 
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