SlideShare une entreprise Scribd logo
1  sur  25
Md. Ali Hosssain
Email:Students.gai@gmail.com
Phone:01731402303
1.

Types of selectors (1)
universal selector (CSS2)




1.

element type selector



1.

applies to: all elements in a page
e.g.:
* { color: red }

applies to: all elements of that type from a page (standard tags)
e.g.:
h2 { color: red }

class selector



applies to: elements defined with that class
e.g.:
.sitetitle { color: red }
HTML:
<div class=“sitetitle”>…
Types of selectors (2)
4.

ID selector




applies to: the single element with that id from the page
e.g.:
#content { color: red }
HTML:
<div id=“content”>…
4.

pseudo-element selector (CSS2)



4.

applies to: the first letter, line or child of the nominated element
e.g.:
p:first-letter { color: red }

pseudo-class selector (CSS2)





applies to: the nominated element in certain conditions
e.g.:
a:hover { color: red }
applies to: all element in a certain language
e.g.:
:lang(ro) { text-decoration: underline }
HTML:
<p xmlns="http://www.w3.org/1999/xhtml" xml:lang="ro">…
Types of selectors (3)
7.

descendant selector


applies to: an element that is a child of another element
 e.g.: p strong { color: red }
HTML: <p>This <strong>paragraph</strong> is long…
7.

parent-child selector (CSS2)


applies to: an element that is a strict child of another
element
 e.g.: body > p { color: red }
9.

Types of selectors (4)
adjacent selector (CSS2)


applies to: an element that appears in the code right after
another
 e.g.: p + span { color: red }
HTML:
<p>This is a paragraph.</p>
<span>this one will be red</span>
<span>this one not</span>
9.

attribute selector (CSS2)



applies to: elements that have a property specified or specified
with a certain value
 e.g.: input[type=“text”] { color: red }
CSS Id and Class
The id and class Selectors
In addition to setting a style for a HTML element, CSS allows you to specify
your own selectors called "id" and "class".
Example

#para1
{
text-align:center;
color:red;
}

The class Selector
The class selector is used to specify a style for a group of elements. Unlike
the id selector, the class selector is most often used on several elements.
Example

.center {text-align:center;}
The <span> and <div> Tags
 These tags are provided to allow arbitrary chunks of

HTML to be treated as elements. This is usually done in
order to apply style attributes to them, as in the preceding
example.

 A <span> ... </span> element defines an “inline”

structure, i.e. it simply defines a stretch of text. Thus it
can be used within a paragraph or table element without
affecting the flow of the text.

 A <div> ... </div> element defines a “block” structure.

Usually the browser will place line breaks before and
after this element, but otherwise it has no effect itself.
Pseudo-classes
These are like style classes, but an element

acquires a pseudo-class by user action or by a
relationship other than decadency.
In the style sheet, a pseudo-class name is

preceded by a colon.
In the HTML, the pseudo-class name is NOT

used with the affected tag, because it is implied.
Pseudo-classes
Link-related pseudo-classes

a:link
{ color : red }
Applies when the link has not yet been visited.

a:visited { color : green }
Applies when the link has been visited.

a:hover
{ color: yellow }
Applies when the mouse is over the link.
Cascading Rule

If two equally specific rules can apply to the

same element, the one that comes last in the
style sheet is used. Thus, in the example below,
a:hover must follow a:link and a:visited in order
to have effect, since a link can be both visited (or
not) and hovering. The order of the first two
doesn’t matter since they are mutually exclusive.
a:link
{ color : red }
a:visited { color : green }
a:hover
{ color : yellow }
Pseudo-elements
Closely related to pseudo-classes, in that they are
defined by relationships, not by explicit declarations. A
pseudo-element refers to a virtual element that is part
of an actual element, rather than a special case of a
whole element.
 :first-line is a pseudo-element that consists of the first

line of text in a block-level element.
 :first-letter is a pseudo-element that consists of the first

letter of the text in an element.
Pseudo-elements
p
p.initial
p.initial:first-line
uppercase }
p.initial:first-letter

{ text-indent: 1em }
{ text-indent: 0 }
{ text-transform:
{ font-size: 24pt }

This indents all normal paragraphs. A paragraph that is
declared with class="initial" is not indented, and its first
line appears in all capital letters, with an extra-large first letter.
The box model
top
margin (transparent)
border
padding

left

Content

bottom

right
Where does it apply
 Margin - Clears an area around the border. The margin does not have a

background color, it is completely transparent
 Border - A border that goes around the padding and content. The border is
affected by the background color of the box
 Padding - Clears an area around the content. The padding is affected by the
background color of the box
 Content - The content of the box, where text and images appear

width:250px;
padding:10px;
border:5px solid gray;
margin:10px;

Let's do the math:
250px (width)
+ 20px (left + right padding)
+ 10px (left + right border)
+ 20px (left + right margin)
= 300px
The margin property can have from one to four
values.
margin:25px 50px 75px 100px;
top margin is 25px
margin:25px 50px;
right margin is 50px
top and bottom margins are 25px
bottom margin is 75px
right and left margins are 50px
left margin is 100px
margin:25px 50px 75px;
top margin is 25px
right and left margins are 50px
bottom margin is 75px

margin:25px;
all four margins are 25px
Example:
Defining an unordered list style:

And writing the HTML code:
Results in:
The display property
Most used values for specifying the display type of an

element:
block – shows a separate block
 e.g. default style for h1, p, form, div

inline – displays inside a text fragment
 e.g. default style for span, em, code

list-item – used for lists
 e.g. default style for li

none
 can be applied to any element
 doesn’t show the element or the space it would take if shown
Positioning (1)
CSS2 provides four types of positioning schemes:
normal
default positioning:
 block boxes flow vertically
 inline boxes flow horizontally
Positioning (2)
relative
done by browsers in two steps:

 first, the normal flow is followed
 the box is moved according to its offset properties (top, right, left,

bottom)

Text text text text text text
text text text text text text…
Text text text text text text
text text text text text text…

paragraph with
relative
positioning,
with positive
top and left
values

Notes:
 use z-index style property to specify their order
 a specific width property might cause an offset to be ignored
Positioning (3)
absolute
the normal flow does not apply and the element is positioned

according to its offset values (top, right, bottom, left)
special case: fixed positioning – the containing block is the viewport
of the browser window
browser window
fixed position
for this
element

the rest of the
content in the
page that must
be scrolled
Scaling
There are two types of lengths units for fonts:
relative
 em: computed value of the ‘font-size’
 ex: ‘x-height’
 px: pixels, relative to the viewing device
absolute
 in: inches
 cm: centimeters
 pt: points
 pc: picas
Positioning

float

specify elements to shift either to the left or right
surrounding content flows around the opposite side
a width should be specified for a floating box

Text text text text
Text
text text text text
text
text text text text
text
text text text text
text text text text text text text
text text text text text text text

Box floating
to the right
Positioning

Note: floating boxes take no space on the vertical side
if a floating box is taller than the first surrounding block, it will float

around the next block, too
solution: clear the floating

Text text text
text text text

text
text
text
text

Text text text
text text text
text text text text text

Text text text
text text text

text
text
text
text

Text text text text text
text text text text text

clear: right
style for this
element
Css class-02

Contenu connexe

Tendances

1 03 - CSS Introduction
1 03 - CSS Introduction1 03 - CSS Introduction
1 03 - CSS Introduction
apnwebdev
 

Tendances (20)

Css ppt
Css pptCss ppt
Css ppt
 
Cascading Style Sheets (CSS) help
Cascading Style Sheets (CSS) helpCascading Style Sheets (CSS) help
Cascading Style Sheets (CSS) help
 
Java script
Java scriptJava script
Java script
 
CSS Day: CSS Grid Layout
CSS Day: CSS Grid Layout CSS Day: CSS Grid Layout
CSS Day: CSS Grid Layout
 
1 03 - CSS Introduction
1 03 - CSS Introduction1 03 - CSS Introduction
1 03 - CSS Introduction
 
Navigation and Link
Navigation and LinkNavigation and Link
Navigation and Link
 
CSS Basics
CSS BasicsCSS Basics
CSS Basics
 
Bootstrap
BootstrapBootstrap
Bootstrap
 
CSS Selectors
CSS SelectorsCSS Selectors
CSS Selectors
 
Jquery
JqueryJquery
Jquery
 
9- Learn CSS Fundamentals / Pseudo-classes
9- Learn CSS Fundamentals / Pseudo-classes9- Learn CSS Fundamentals / Pseudo-classes
9- Learn CSS Fundamentals / Pseudo-classes
 
html-css
html-csshtml-css
html-css
 
Java Script ppt
Java Script pptJava Script ppt
Java Script ppt
 
Javascript basics
Javascript basicsJavascript basics
Javascript basics
 
JavaScript - Chapter 8 - Objects
 JavaScript - Chapter 8 - Objects JavaScript - Chapter 8 - Objects
JavaScript - Chapter 8 - Objects
 
How Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) WorksHow Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) Works
 
CSS Font & Text style
CSS Font & Text style CSS Font & Text style
CSS Font & Text style
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
CSS
CSSCSS
CSS
 
CSS
CSSCSS
CSS
 

En vedette

New Elements & Features in CSS3
New Elements & Features in CSS3New Elements & Features in CSS3
New Elements & Features in CSS3
Jamshid Hashimi
 

En vedette (20)

Css2
Css2Css2
Css2
 
CSS 3 Overview
CSS 3 OverviewCSS 3 Overview
CSS 3 Overview
 
CSS3 : Animation ,Transitions, Gradients
CSS3 : Animation ,Transitions, GradientsCSS3 : Animation ,Transitions, Gradients
CSS3 : Animation ,Transitions, Gradients
 
New Elements & Features in CSS3
New Elements & Features in CSS3New Elements & Features in CSS3
New Elements & Features in CSS3
 
Css2
Css2Css2
Css2
 
Css3 animation
Css3 animationCss3 animation
Css3 animation
 
Intro to CSS3
Intro to CSS3Intro to CSS3
Intro to CSS3
 
Introduction to HTML5 & CSS3
Introduction to HTML5 & CSS3Introduction to HTML5 & CSS3
Introduction to HTML5 & CSS3
 
Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)
 
CSS ppt
CSS pptCSS ppt
CSS ppt
 
cascading style sheet ppt
cascading style sheet pptcascading style sheet ppt
cascading style sheet ppt
 
Biodiesel Use, Handling, and Fuel Quality
Biodiesel Use, Handling, and Fuel QualityBiodiesel Use, Handling, and Fuel Quality
Biodiesel Use, Handling, and Fuel Quality
 
Sorghum Syrup
Sorghum SyrupSorghum Syrup
Sorghum Syrup
 
Squash Bug and Squash Vine Borer: Organic Controls
Squash Bug and Squash Vine Borer: Organic ControlsSquash Bug and Squash Vine Borer: Organic Controls
Squash Bug and Squash Vine Borer: Organic Controls
 
Bug Vacuums for Organic Crop Protection
Bug Vacuums for Organic Crop ProtectionBug Vacuums for Organic Crop Protection
Bug Vacuums for Organic Crop Protection
 
Fiji luncheon presentation
Fiji luncheon presentationFiji luncheon presentation
Fiji luncheon presentation
 
Konsultupphandling enligt abk09
Konsultupphandling enligt abk09Konsultupphandling enligt abk09
Konsultupphandling enligt abk09
 
5th sunday in ordinary time feb9, 2014
5th sunday in ordinary time feb9, 20145th sunday in ordinary time feb9, 2014
5th sunday in ordinary time feb9, 2014
 
6th sunday in ordinary time feb16, 2014
6th sunday in ordinary time feb16, 20146th sunday in ordinary time feb16, 2014
6th sunday in ordinary time feb16, 2014
 
Plain text
Plain textPlain text
Plain text
 

Similaire à Css class-02

Similaire à Css class-02 (20)

5. Web Technology CSS Advanced
5. Web Technology CSS Advanced 5. Web Technology CSS Advanced
5. Web Technology CSS Advanced
 
Lecture2 CSS 2
Lecture2  CSS 2Lecture2  CSS 2
Lecture2 CSS 2
 
Basic css
Basic cssBasic css
Basic css
 
Css Introduction
Css IntroductionCss Introduction
Css Introduction
 
Css from scratch
Css from scratchCss from scratch
Css from scratch
 
Web engineering
Web engineeringWeb engineering
Web engineering
 
Css
CssCss
Css
 
Css basics
Css basicsCss basics
Css basics
 
Web Programming-css.pptx
Web Programming-css.pptxWeb Programming-css.pptx
Web Programming-css.pptx
 
Css selectors
Css selectorsCss selectors
Css selectors
 
Lec 1
Lec 1Lec 1
Lec 1
 
Css advanced – session 4
Css advanced – session 4Css advanced – session 4
Css advanced – session 4
 
Css
CssCss
Css
 
Art of css
Art of cssArt of css
Art of css
 
Css advanced – session 5
Css advanced – session 5Css advanced – session 5
Css advanced – session 5
 
Cascading Style Sheets
Cascading Style SheetsCascading Style Sheets
Cascading Style Sheets
 
CSS
CSSCSS
CSS
 
Css.prabu
Css.prabuCss.prabu
Css.prabu
 
Css lecture notes
Css lecture notesCss lecture notes
Css lecture notes
 
Types of Selectors (HTML)
Types of Selectors (HTML)Types of Selectors (HTML)
Types of Selectors (HTML)
 

Plus de Md Ali Hossain (20)

Job environment (for new employee)
Job  environment (for new employee) Job  environment (for new employee)
Job environment (for new employee)
 
Web offset presses
Web offset pressesWeb offset presses
Web offset presses
 
Modern printing technologies
Modern printing technologiesModern printing technologies
Modern printing technologies
 
Screen printing
Screen printingScreen printing
Screen printing
 
Color
ColorColor
Color
 
Flexography
FlexographyFlexography
Flexography
 
Offset printing platon press
Offset printing platon pressOffset printing platon press
Offset printing platon press
 
Flexographic printing 1(9551)
Flexographic printing 1(9551)Flexographic printing 1(9551)
Flexographic printing 1(9551)
 
Press mentainense(9553)
Press mentainense(9553)Press mentainense(9553)
Press mentainense(9553)
 
Flexographic printing 1(9551)
Flexographic printing 1(9551)Flexographic printing 1(9551)
Flexographic printing 1(9551)
 
Special printing
Special printingSpecial printing
Special printing
 
142
142142
142
 
Web authoring design-basics
Web authoring design-basicsWeb authoring design-basics
Web authoring design-basics
 
Site designer
Site designerSite designer
Site designer
 
Webdesign
WebdesignWebdesign
Webdesign
 
Httml flash
Httml flashHttml flash
Httml flash
 
Html class-07
Html class-07Html class-07
Html class-07
 
Html class-04
Html class-04Html class-04
Html class-04
 
Html class-02
Html class-02Html class-02
Html class-02
 
Css class-01
Css class-01Css class-01
Css class-01
 

Dernier

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Dernier (20)

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

Css class-02

  • 2. 1. Types of selectors (1) universal selector (CSS2)   1. element type selector   1. applies to: all elements in a page e.g.: * { color: red } applies to: all elements of that type from a page (standard tags) e.g.: h2 { color: red } class selector   applies to: elements defined with that class e.g.: .sitetitle { color: red } HTML: <div class=“sitetitle”>…
  • 3. Types of selectors (2) 4. ID selector   applies to: the single element with that id from the page e.g.: #content { color: red } HTML: <div id=“content”>… 4. pseudo-element selector (CSS2)   4. applies to: the first letter, line or child of the nominated element e.g.: p:first-letter { color: red } pseudo-class selector (CSS2)     applies to: the nominated element in certain conditions e.g.: a:hover { color: red } applies to: all element in a certain language e.g.: :lang(ro) { text-decoration: underline } HTML: <p xmlns="http://www.w3.org/1999/xhtml" xml:lang="ro">…
  • 4. Types of selectors (3) 7. descendant selector  applies to: an element that is a child of another element  e.g.: p strong { color: red } HTML: <p>This <strong>paragraph</strong> is long… 7. parent-child selector (CSS2)  applies to: an element that is a strict child of another element  e.g.: body > p { color: red }
  • 5. 9. Types of selectors (4) adjacent selector (CSS2)  applies to: an element that appears in the code right after another  e.g.: p + span { color: red } HTML: <p>This is a paragraph.</p> <span>this one will be red</span> <span>this one not</span> 9. attribute selector (CSS2)  applies to: elements that have a property specified or specified with a certain value  e.g.: input[type=“text”] { color: red }
  • 6. CSS Id and Class The id and class Selectors In addition to setting a style for a HTML element, CSS allows you to specify your own selectors called "id" and "class". Example #para1 { text-align:center; color:red; } The class Selector The class selector is used to specify a style for a group of elements. Unlike the id selector, the class selector is most often used on several elements. Example .center {text-align:center;}
  • 7. The <span> and <div> Tags  These tags are provided to allow arbitrary chunks of HTML to be treated as elements. This is usually done in order to apply style attributes to them, as in the preceding example.  A <span> ... </span> element defines an “inline” structure, i.e. it simply defines a stretch of text. Thus it can be used within a paragraph or table element without affecting the flow of the text.  A <div> ... </div> element defines a “block” structure. Usually the browser will place line breaks before and after this element, but otherwise it has no effect itself.
  • 8. Pseudo-classes These are like style classes, but an element acquires a pseudo-class by user action or by a relationship other than decadency. In the style sheet, a pseudo-class name is preceded by a colon. In the HTML, the pseudo-class name is NOT used with the affected tag, because it is implied.
  • 9. Pseudo-classes Link-related pseudo-classes a:link { color : red } Applies when the link has not yet been visited. a:visited { color : green } Applies when the link has been visited. a:hover { color: yellow } Applies when the mouse is over the link.
  • 10. Cascading Rule If two equally specific rules can apply to the same element, the one that comes last in the style sheet is used. Thus, in the example below, a:hover must follow a:link and a:visited in order to have effect, since a link can be both visited (or not) and hovering. The order of the first two doesn’t matter since they are mutually exclusive. a:link { color : red } a:visited { color : green } a:hover { color : yellow }
  • 11. Pseudo-elements Closely related to pseudo-classes, in that they are defined by relationships, not by explicit declarations. A pseudo-element refers to a virtual element that is part of an actual element, rather than a special case of a whole element.  :first-line is a pseudo-element that consists of the first line of text in a block-level element.  :first-letter is a pseudo-element that consists of the first letter of the text in an element.
  • 12. Pseudo-elements p p.initial p.initial:first-line uppercase } p.initial:first-letter { text-indent: 1em } { text-indent: 0 } { text-transform: { font-size: 24pt } This indents all normal paragraphs. A paragraph that is declared with class="initial" is not indented, and its first line appears in all capital letters, with an extra-large first letter.
  • 13. The box model top margin (transparent) border padding left Content bottom right
  • 14. Where does it apply  Margin - Clears an area around the border. The margin does not have a background color, it is completely transparent  Border - A border that goes around the padding and content. The border is affected by the background color of the box  Padding - Clears an area around the content. The padding is affected by the background color of the box  Content - The content of the box, where text and images appear width:250px; padding:10px; border:5px solid gray; margin:10px; Let's do the math: 250px (width) + 20px (left + right padding) + 10px (left + right border) + 20px (left + right margin) = 300px
  • 15. The margin property can have from one to four values. margin:25px 50px 75px 100px; top margin is 25px margin:25px 50px; right margin is 50px top and bottom margins are 25px bottom margin is 75px right and left margins are 50px left margin is 100px margin:25px 50px 75px; top margin is 25px right and left margins are 50px bottom margin is 75px margin:25px; all four margins are 25px
  • 16. Example: Defining an unordered list style: And writing the HTML code:
  • 18. The display property Most used values for specifying the display type of an element: block – shows a separate block  e.g. default style for h1, p, form, div inline – displays inside a text fragment  e.g. default style for span, em, code list-item – used for lists  e.g. default style for li none  can be applied to any element  doesn’t show the element or the space it would take if shown
  • 19. Positioning (1) CSS2 provides four types of positioning schemes: normal default positioning:  block boxes flow vertically  inline boxes flow horizontally
  • 20. Positioning (2) relative done by browsers in two steps:  first, the normal flow is followed  the box is moved according to its offset properties (top, right, left, bottom) Text text text text text text text text text text text text… Text text text text text text text text text text text text… paragraph with relative positioning, with positive top and left values Notes:  use z-index style property to specify their order  a specific width property might cause an offset to be ignored
  • 21. Positioning (3) absolute the normal flow does not apply and the element is positioned according to its offset values (top, right, bottom, left) special case: fixed positioning – the containing block is the viewport of the browser window browser window fixed position for this element the rest of the content in the page that must be scrolled
  • 22. Scaling There are two types of lengths units for fonts: relative  em: computed value of the ‘font-size’  ex: ‘x-height’  px: pixels, relative to the viewing device absolute  in: inches  cm: centimeters  pt: points  pc: picas
  • 23. Positioning float specify elements to shift either to the left or right surrounding content flows around the opposite side a width should be specified for a floating box Text text text text Text text text text text text text text text text text text text text text text text text text text text text text text text text text text text Box floating to the right
  • 24. Positioning Note: floating boxes take no space on the vertical side if a floating box is taller than the first surrounding block, it will float around the next block, too solution: clear the floating Text text text text text text text text text text Text text text text text text text text text text text Text text text text text text text text text text Text text text text text text text text text text clear: right style for this element