SlideShare ist ein Scribd-Unternehmen logo
1 von 36
Formatting Text with CSS
Objectives
Assess web fonts
Declare a font family
Use a custom font
Declare font size and line height
Implement bold and italics
HTML5 and CSS3 – Illustrated, 2nd Edition 2
Objectives (continued)
Style pseudo-elements
Specify hex and RGB colors
Add shadows
Create a media query
HTML5 and CSS3 – Illustrated, 2nd Edition 3
Assess Web Fonts
Web page font display limited by fonts
available on users’ machines
How to implement fonts consistently:
 Specify multiple font families
‱ Font stack: List of font families in order of
preference, separated by commas
 Specify a generic font family
‱ Generic font families: grouping of font
families according to shared characteristics
‱ Add to end of font stack
HTML5 and CSS3 – Illustrated, 2nd Edition 4
Assess Web Fonts
(continued)
How to implement fonts consistently
(continued):
 Use downloadable fonts
‱ User agent downloads and applies fonts not
installed on user’s computer
‱ Upload file containing elements of the font
family to web publishing location or reference
licensed downloadable font
‱ Add @font-face rule to style sheet
– Indicates font name and location of necessary files
HTML5 and CSS3 – Illustrated, 2nd Edition 5
Assess Web Fonts
(continued)
Commonly used font stacks
Generic font families
HTML5 and CSS3 – Illustrated, 2nd Edition 6
Declare a Font Family
font-family property: Used to
specify fonts in CSS
 Value is font stack that includes font
family name(s) and ends with generic
font family name
 Can be included in any style rule to apply
to elements selected in that rule
Test all fonts in your font stack
 Use browser developer tools to test and
not permanently changing the CSS code
HTML5 and CSS3 – Illustrated, 2nd Edition 7
Declare a Font Family (continued)
Code with font-family declarations
and display
HTML5 and CSS3 – Illustrated, 2nd Edition 8
Use a Custom Font
Custom fonts help to
 Create uniformity
 Add wider font possibilities
Available online, e.g.
 Google.com/fonts
 Defaults to only the normal version of
font
 Make selections to make other versions,
such as bold or italic, available
HTML5 and CSS3 – Illustrated, 2nd Edition 9
Use a Custom Font (continued)
Code with link element to custom font
Custom font added to font stack
HTML5 and CSS3 – Illustrated, 2nd Edition 10
Declare Font Size
and Line Height
font-size property: used to specify
font size of an element
 Can specify size in many different units
Useful to specify font-sizes in style
sheet to standardize visual display of
font size in different browsers
 Specify html element in px
 Specify other elements in em or rem
HTML5 and CSS3 – Illustrated, 2nd Edition 11
Declare Font Size and
Line Height (continued)
By default, each font family includes
blank space above and below every
line of text
Use line-height property to set
minimum amount of vertical space
each line occupies
Adjusting line-height helps create
white space, which is used for visual
effect
HTML5 and CSS3 – Illustrated, 2nd Edition 12
Declare Font Size and
Line Height (continued)
Code and resulting presentation
HTML5 and CSS3 – Illustrated, 2nd Edition 13
Implement Bold and Italics
Bold and italics often applied to words
or phrases
Use span element to isolate specific
sections for formatting:
 span element creates an inline element
‱ Does not fill space of parent element
‱ Is not rendered with line breaks before or
after
‱ Assign class value to span element
HTML5 and CSS3 – Illustrated, 2nd Edition 14
Implement Bold and Italics
(continued)
CSS font properties to format text
 Font-weight for bold
 Font-style for italic
HTML5 and CSS3 – Illustrated, 2nd Edition 15
Implement Bold and Italics
(continued)
Span element added
span element rendered
HTML5 and CSS3 – Illustrated, 2nd Edition 16
Style Pseudo-Elements
Pseudo-element: selector that enables
you to isolate a portion of a larger
element for styling
 Selector format example
‱article p:first-line
Create a drop cap
 Use :first-letter pseudo-element
 Use float property
 Use line-height property
HTML5 and CSS3 – Illustrated, 2nd Edition 17
Style Pseudo-Elements
(continued)
CSS pseudo-elements
HTML5 and CSS3 – Illustrated, 2nd Edition 18
Style Pseudo-Elements
(continued)
Code for :first-line and
:first-letter pseudo-elements
HTML5 and CSS3 – Illustrated, 2nd Edition 19
Style Pseudo-Elements
(continued)
Pseudo-elements rendered in browser
HTML5 and CSS3 – Illustrated, 2nd Edition 20
Specify Hex and RGB
Colors
color and background-color
properties: used to specify the color of
text and other HTML elements
Four ways to specify colors:
 color name
 hexadecimal format
 rgb format, includes rgba
 hsl format, includes hsla
HTML5 and CSS3 – Illustrated, 2nd Edition 21
Specify Hex and RGB
Colors (continued)
CSS color systems
HTML5 and CSS3 – Illustrated, 2nd Edition 22
Specify Hex and RGB
Colors (continued)
Code using hex and rgb colors
HTML5 and CSS3 – Illustrated, 2nd Edition 23
Specify Hex and RGB
Colors (continued)
hex and rgb color codes rendered in
a browser
HTML5 and CSS3 – Illustrated, 2nd Edition 24
Add Shadows
text-shadow: creates the
appearance of a shadow behind text
box-shadow: creates the appearance
of a shadow behind an element
text-shadow and box-shadow both
 Support four values: horizontal offset,
vertical offset, blur, and shadow color
box-shadow also supports
 Spread distance and insetHTML5 and CSS3 – Illustrated, 2nd Edition 25
Add Shadows
(continued)
Syntax of the text-shadow and
box-shadow properties
HTML5 and CSS3 – Illustrated, 2nd Edition 26
Add Shadows
(continued)
Examples of text-shadow and box-
shadow
HTML5 and CSS3 – Illustrated, 2nd Edition 27
Add Shadows
(continued)
Code for text-shadow and box-
shadow and resulting web page
HTML5 and CSS3 – Illustrated, 2nd Edition 28
Create a Media Query
Media queries: used to create a group
of rules for a specific device
 Starts with @media
 Lists one or more values for media type
Media type values for media queries
HTML5 and CSS3 – Illustrated, 2nd Edition 29
Create a Media Query
(continued)
HTML5 and CSS3 – Illustrated, 2nd Edition 30
Code for media query for printed
output
Create a Media Query
(continued)
HTML5 and CSS3 – Illustrated, 2nd Edition 31
Printed output based on media query
Summary
It is important to implement fonts so
that they will be displayed consistently
on different user agents
Font stacks are declared using the
font-family property
span element: generic element used
to isolate a portion of another element
 Used to create an inline element
HTML5 and CSS3 – Illustrated, 2nd Edition 32
Summary (continued)
Use custom fonts to widen font
possibilities and to create uniformity
Different aspects of font can be set
using CSS properties, such as:
 font-size property: set the font size
 font-weight property: make font bold
 font-style property: make font italic
Use line-height property to create
space above and below every line of
text
HTML5 and CSS3 – Illustrated, 2nd Edition 33
Summary (continued)
span element: generic element used
to isolate a portion of another element
 Used to create an inline element
 Used to apply bold/italic to text specified
by span element
Pseudo-elements to style a portion of
an element
:before and :after allow you to
generate repeated content from style
rules, without changing HTML code
HTML5 and CSS3 – Illustrated, 2nd Edition 34
Summary (continued)
In CSS, colors specified by name,
rgb/rgba, hex, or hsl/hsla value
 color property: sets font color
 background property: sets background
color
text-shadow and box-shadow
properties used to create shadows
 both support: horizontal/vertical offset,
blur radius, color
 box-shadow only supports: spread
distance, inset
HTML5 and CSS3 – Illustrated, 2nd Edition 35
Summary (continued)
Media query specifies style rules for a
specific device
 Starts with @media
 Supports media type values: all,
print, screen, and speech
HTML5 and CSS3 – Illustrated, 2nd Edition 36

Weitere Àhnliche Inhalte

Was ist angesagt?

Dreamweaver Ch03
Dreamweaver Ch03Dreamweaver Ch03
Dreamweaver Ch03
Frank Fucile
 
M02 un12 p01
M02 un12 p01M02 un12 p01
M02 un12 p01
Intan Jameel
 
Crystal report generation in visual studio 2010
Crystal report generation in visual studio 2010Crystal report generation in visual studio 2010
Crystal report generation in visual studio 2010
Slideshare
 
Quickstart Microsoft access 2013
Quickstart Microsoft access 2013Quickstart Microsoft access 2013
Quickstart Microsoft access 2013
comatsg
 
Psd to html
Psd to htmlPsd to html
Psd to html
Len Biel
 

Was ist angesagt? (20)

Laying Out Elements with CSS
Laying Out Elements with CSSLaying Out Elements with CSS
Laying Out Elements with CSS
 
Optimizing a website for search engines
Optimizing a website for search enginesOptimizing a website for search engines
Optimizing a website for search engines
 
Creating and Processing Web Forms
Creating and Processing Web FormsCreating and Processing Web Forms
Creating and Processing Web Forms
 
Working with Video and Audio
Working with Video and AudioWorking with Video and Audio
Working with Video and Audio
 
Social media and your website
Social media and your websiteSocial media and your website
Social media and your website
 
Dreamweaver Ch03
Dreamweaver Ch03Dreamweaver Ch03
Dreamweaver Ch03
 
Crystal report
Crystal reportCrystal report
Crystal report
 
Presentation on HTML
Presentation on HTML Presentation on HTML
Presentation on HTML
 
M02 un12 p01
M02 un12 p01M02 un12 p01
M02 un12 p01
 
Crystal report
Crystal reportCrystal report
Crystal report
 
Css 2010
Css 2010Css 2010
Css 2010
 
Crystal report generation in visual studio 2010
Crystal report generation in visual studio 2010Crystal report generation in visual studio 2010
Crystal report generation in visual studio 2010
 
Content Architecture
Content ArchitectureContent Architecture
Content Architecture
 
Introduction To Flex
Introduction To FlexIntroduction To Flex
Introduction To Flex
 
Introduction to HTML
Introduction to HTMLIntroduction to HTML
Introduction to HTML
 
C# Crystal Reports
C# Crystal ReportsC# Crystal Reports
C# Crystal Reports
 
Front End Ui with React online training | Front End Ui with React training | ...
Front End Ui with React online training | Front End Ui with React training | ...Front End Ui with React online training | Front End Ui with React training | ...
Front End Ui with React online training | Front End Ui with React training | ...
 
Front end UI with React online training | Front end UI with React training | ...
Front end UI with React online training | Front end UI with React training | ...Front end UI with React online training | Front end UI with React training | ...
Front end UI with React online training | Front end UI with React training | ...
 
Quickstart Microsoft access 2013
Quickstart Microsoft access 2013Quickstart Microsoft access 2013
Quickstart Microsoft access 2013
 
Psd to html
Psd to htmlPsd to html
Psd to html
 

Andere mochten auch

Andere mochten auch (11)

Organizing Content with Lists and Tables
Organizing Content with Lists and TablesOrganizing Content with Lists and Tables
Organizing Content with Lists and Tables
 
Everything You know about CSS is Wrong
Everything You know about CSS is WrongEverything You know about CSS is Wrong
Everything You know about CSS is Wrong
 
Microsoft TechDays - CSS3 Presentation
Microsoft TechDays - CSS3 PresentationMicrosoft TechDays - CSS3 Presentation
Microsoft TechDays - CSS3 Presentation
 
The Future State of Layout
The Future State of LayoutThe Future State of Layout
The Future State of Layout
 
CSS: a rapidly changing world
CSS: a rapidly changing worldCSS: a rapidly changing world
CSS: a rapidly changing world
 
CSS3: A practical introduction (FT2010 talk)
CSS3: A practical introduction (FT2010 talk)CSS3: A practical introduction (FT2010 talk)
CSS3: A practical introduction (FT2010 talk)
 
CSS3 secrets: 10 things you might not know about CSS3
CSS3 secrets: 10 things you might not know about CSS3CSS3 secrets: 10 things you might not know about CSS3
CSS3 secrets: 10 things you might not know about CSS3
 
Tutorial: Html5 And Css3 Site
Tutorial: Html5 And Css3 SiteTutorial: Html5 And Css3 Site
Tutorial: Html5 And Css3 Site
 
CSS3 Layout
CSS3 LayoutCSS3 Layout
CSS3 Layout
 
CSS3 - is everything we used to do wrong?
CSS3 - is everything we used to do wrong? CSS3 - is everything we used to do wrong?
CSS3 - is everything we used to do wrong?
 
Python Dictionaries and Sets
Python Dictionaries and SetsPython Dictionaries and Sets
Python Dictionaries and Sets
 

Ähnlich wie Formatting text with CSS

Styling text using css
Styling text using cssStyling text using css
Styling text using css
Daniel Francis
 

Ähnlich wie Formatting text with CSS (20)

Introduction to CSS3
Introduction to CSS3Introduction to CSS3
Introduction to CSS3
 
Css
CssCss
Css
 
Css
CssCss
Css
 
Visual Experience 360 Flex
Visual Experience 360 FlexVisual Experience 360 Flex
Visual Experience 360 Flex
 
SDP_-_Module_4.ppt
SDP_-_Module_4.pptSDP_-_Module_4.ppt
SDP_-_Module_4.ppt
 
Css Founder.com | Cssfounder Company
Css Founder.com | Cssfounder CompanyCss Founder.com | Cssfounder Company
Css Founder.com | Cssfounder Company
 
IT2255 Web Essentials - Unit II Web Designing
IT2255 Web Essentials - Unit II  Web DesigningIT2255 Web Essentials - Unit II  Web Designing
IT2255 Web Essentials - Unit II Web Designing
 
WEB DEVELOPMENT
WEB DEVELOPMENTWEB DEVELOPMENT
WEB DEVELOPMENT
 
CSS 3 Overview
CSS 3 OverviewCSS 3 Overview
CSS 3 Overview
 
Css basics
Css basicsCss basics
Css basics
 
CSS3
CSS3CSS3
CSS3
 
Adobe Flex Don't Style It, Skin it!
Adobe Flex Don't Style It, Skin it!Adobe Flex Don't Style It, Skin it!
Adobe Flex Don't Style It, Skin it!
 
Css
CssCss
Css
 
Building Next Generation Websites Session5
Building Next Generation Websites Session5Building Next Generation Websites Session5
Building Next Generation Websites Session5
 
Building Next Generation Websites by Muhammad Ehtisham Siddiqui
Building Next Generation Websites by Muhammad Ehtisham SiddiquiBuilding Next Generation Websites by Muhammad Ehtisham Siddiqui
Building Next Generation Websites by Muhammad Ehtisham Siddiqui
 
Web Engineering - Introduction to CSS
Web Engineering - Introduction to CSSWeb Engineering - Introduction to CSS
Web Engineering - Introduction to CSS
 
Styling text using css
Styling text using cssStyling text using css
Styling text using css
 
WEB DEVELOPMENT
WEB DEVELOPMENTWEB DEVELOPMENT
WEB DEVELOPMENT
 
Lecture 5
Lecture 5Lecture 5
Lecture 5
 
Le Wagon Tokyo | Build your Landing Page in 2 hours
Le Wagon Tokyo | Build your Landing Page in 2 hoursLe Wagon Tokyo | Build your Landing Page in 2 hours
Le Wagon Tokyo | Build your Landing Page in 2 hours
 

Mehr von Nicole Ryan

Mehr von Nicole Ryan (15)

Inheritance
InheritanceInheritance
Inheritance
 
Chapter 12 Lecture: GUI Programming, Multithreading, and Animation
Chapter 12 Lecture: GUI Programming, Multithreading, and AnimationChapter 12 Lecture: GUI Programming, Multithreading, and Animation
Chapter 12 Lecture: GUI Programming, Multithreading, and Animation
 
Chapter 11: Object Oriented Programming Part 2
Chapter 11: Object Oriented Programming Part 2Chapter 11: Object Oriented Programming Part 2
Chapter 11: Object Oriented Programming Part 2
 
Intro to Programming: Modularity
Intro to Programming: ModularityIntro to Programming: Modularity
Intro to Programming: Modularity
 
Programming Logic and Design: Arrays
Programming Logic and Design: ArraysProgramming Logic and Design: Arrays
Programming Logic and Design: Arrays
 
Programming Logic and Design: Working with Data
Programming Logic and Design: Working with DataProgramming Logic and Design: Working with Data
Programming Logic and Design: Working with Data
 
Setting up your development environment
Setting up your development environmentSetting up your development environment
Setting up your development environment
 
Dynamic vs static
Dynamic vs staticDynamic vs static
Dynamic vs static
 
Working with Databases and MySQL
Working with Databases and MySQLWorking with Databases and MySQL
Working with Databases and MySQL
 
Using arrays with PHP for forms and storing information
Using arrays with PHP for forms and storing informationUsing arrays with PHP for forms and storing information
Using arrays with PHP for forms and storing information
 
Tables and forms accessibility and microformats
Tables and forms accessibility and microformatsTables and forms accessibility and microformats
Tables and forms accessibility and microformats
 
Creating and styling forms
Creating and styling formsCreating and styling forms
Creating and styling forms
 
Creating and styling tables
Creating and styling tablesCreating and styling tables
Creating and styling tables
 
Files and Directories in PHP
Files and Directories in PHPFiles and Directories in PHP
Files and Directories in PHP
 
Handling User Input and Processing Form Data
Handling User Input and Processing Form DataHandling User Input and Processing Form Data
Handling User Input and Processing Form Data
 

KĂŒrzlich hochgeladen

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

KĂŒrzlich hochgeladen (20)

FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
80 ĐỀ THI THỏ TUYỂN SINH TIáșŸNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỏ TUYỂN SINH TIáșŸNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỏ TUYỂN SINH TIáșŸNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỏ TUYỂN SINH TIáșŸNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 

Formatting text with CSS

  • 2. Objectives Assess web fonts Declare a font family Use a custom font Declare font size and line height Implement bold and italics HTML5 and CSS3 – Illustrated, 2nd Edition 2
  • 3. Objectives (continued) Style pseudo-elements Specify hex and RGB colors Add shadows Create a media query HTML5 and CSS3 – Illustrated, 2nd Edition 3
  • 4. Assess Web Fonts Web page font display limited by fonts available on users’ machines How to implement fonts consistently:  Specify multiple font families ‱ Font stack: List of font families in order of preference, separated by commas  Specify a generic font family ‱ Generic font families: grouping of font families according to shared characteristics ‱ Add to end of font stack HTML5 and CSS3 – Illustrated, 2nd Edition 4
  • 5. Assess Web Fonts (continued) How to implement fonts consistently (continued):  Use downloadable fonts ‱ User agent downloads and applies fonts not installed on user’s computer ‱ Upload file containing elements of the font family to web publishing location or reference licensed downloadable font ‱ Add @font-face rule to style sheet – Indicates font name and location of necessary files HTML5 and CSS3 – Illustrated, 2nd Edition 5
  • 6. Assess Web Fonts (continued) Commonly used font stacks Generic font families HTML5 and CSS3 – Illustrated, 2nd Edition 6
  • 7. Declare a Font Family font-family property: Used to specify fonts in CSS  Value is font stack that includes font family name(s) and ends with generic font family name  Can be included in any style rule to apply to elements selected in that rule Test all fonts in your font stack  Use browser developer tools to test and not permanently changing the CSS code HTML5 and CSS3 – Illustrated, 2nd Edition 7
  • 8. Declare a Font Family (continued) Code with font-family declarations and display HTML5 and CSS3 – Illustrated, 2nd Edition 8
  • 9. Use a Custom Font Custom fonts help to  Create uniformity  Add wider font possibilities Available online, e.g.  Google.com/fonts  Defaults to only the normal version of font  Make selections to make other versions, such as bold or italic, available HTML5 and CSS3 – Illustrated, 2nd Edition 9
  • 10. Use a Custom Font (continued) Code with link element to custom font Custom font added to font stack HTML5 and CSS3 – Illustrated, 2nd Edition 10
  • 11. Declare Font Size and Line Height font-size property: used to specify font size of an element  Can specify size in many different units Useful to specify font-sizes in style sheet to standardize visual display of font size in different browsers  Specify html element in px  Specify other elements in em or rem HTML5 and CSS3 – Illustrated, 2nd Edition 11
  • 12. Declare Font Size and Line Height (continued) By default, each font family includes blank space above and below every line of text Use line-height property to set minimum amount of vertical space each line occupies Adjusting line-height helps create white space, which is used for visual effect HTML5 and CSS3 – Illustrated, 2nd Edition 12
  • 13. Declare Font Size and Line Height (continued) Code and resulting presentation HTML5 and CSS3 – Illustrated, 2nd Edition 13
  • 14. Implement Bold and Italics Bold and italics often applied to words or phrases Use span element to isolate specific sections for formatting:  span element creates an inline element ‱ Does not fill space of parent element ‱ Is not rendered with line breaks before or after ‱ Assign class value to span element HTML5 and CSS3 – Illustrated, 2nd Edition 14
  • 15. Implement Bold and Italics (continued) CSS font properties to format text  Font-weight for bold  Font-style for italic HTML5 and CSS3 – Illustrated, 2nd Edition 15
  • 16. Implement Bold and Italics (continued) Span element added span element rendered HTML5 and CSS3 – Illustrated, 2nd Edition 16
  • 17. Style Pseudo-Elements Pseudo-element: selector that enables you to isolate a portion of a larger element for styling  Selector format example ‱article p:first-line Create a drop cap  Use :first-letter pseudo-element  Use float property  Use line-height property HTML5 and CSS3 – Illustrated, 2nd Edition 17
  • 18. Style Pseudo-Elements (continued) CSS pseudo-elements HTML5 and CSS3 – Illustrated, 2nd Edition 18
  • 19. Style Pseudo-Elements (continued) Code for :first-line and :first-letter pseudo-elements HTML5 and CSS3 – Illustrated, 2nd Edition 19
  • 20. Style Pseudo-Elements (continued) Pseudo-elements rendered in browser HTML5 and CSS3 – Illustrated, 2nd Edition 20
  • 21. Specify Hex and RGB Colors color and background-color properties: used to specify the color of text and other HTML elements Four ways to specify colors:  color name  hexadecimal format  rgb format, includes rgba  hsl format, includes hsla HTML5 and CSS3 – Illustrated, 2nd Edition 21
  • 22. Specify Hex and RGB Colors (continued) CSS color systems HTML5 and CSS3 – Illustrated, 2nd Edition 22
  • 23. Specify Hex and RGB Colors (continued) Code using hex and rgb colors HTML5 and CSS3 – Illustrated, 2nd Edition 23
  • 24. Specify Hex and RGB Colors (continued) hex and rgb color codes rendered in a browser HTML5 and CSS3 – Illustrated, 2nd Edition 24
  • 25. Add Shadows text-shadow: creates the appearance of a shadow behind text box-shadow: creates the appearance of a shadow behind an element text-shadow and box-shadow both  Support four values: horizontal offset, vertical offset, blur, and shadow color box-shadow also supports  Spread distance and insetHTML5 and CSS3 – Illustrated, 2nd Edition 25
  • 26. Add Shadows (continued) Syntax of the text-shadow and box-shadow properties HTML5 and CSS3 – Illustrated, 2nd Edition 26
  • 27. Add Shadows (continued) Examples of text-shadow and box- shadow HTML5 and CSS3 – Illustrated, 2nd Edition 27
  • 28. Add Shadows (continued) Code for text-shadow and box- shadow and resulting web page HTML5 and CSS3 – Illustrated, 2nd Edition 28
  • 29. Create a Media Query Media queries: used to create a group of rules for a specific device  Starts with @media  Lists one or more values for media type Media type values for media queries HTML5 and CSS3 – Illustrated, 2nd Edition 29
  • 30. Create a Media Query (continued) HTML5 and CSS3 – Illustrated, 2nd Edition 30 Code for media query for printed output
  • 31. Create a Media Query (continued) HTML5 and CSS3 – Illustrated, 2nd Edition 31 Printed output based on media query
  • 32. Summary It is important to implement fonts so that they will be displayed consistently on different user agents Font stacks are declared using the font-family property span element: generic element used to isolate a portion of another element  Used to create an inline element HTML5 and CSS3 – Illustrated, 2nd Edition 32
  • 33. Summary (continued) Use custom fonts to widen font possibilities and to create uniformity Different aspects of font can be set using CSS properties, such as:  font-size property: set the font size  font-weight property: make font bold  font-style property: make font italic Use line-height property to create space above and below every line of text HTML5 and CSS3 – Illustrated, 2nd Edition 33
  • 34. Summary (continued) span element: generic element used to isolate a portion of another element  Used to create an inline element  Used to apply bold/italic to text specified by span element Pseudo-elements to style a portion of an element :before and :after allow you to generate repeated content from style rules, without changing HTML code HTML5 and CSS3 – Illustrated, 2nd Edition 34
  • 35. Summary (continued) In CSS, colors specified by name, rgb/rgba, hex, or hsl/hsla value  color property: sets font color  background property: sets background color text-shadow and box-shadow properties used to create shadows  both support: horizontal/vertical offset, blur radius, color  box-shadow only supports: spread distance, inset HTML5 and CSS3 – Illustrated, 2nd Edition 35
  • 36. Summary (continued) Media query specifies style rules for a specific device  Starts with @media  Supports media type values: all, print, screen, and speech HTML5 and CSS3 – Illustrated, 2nd Edition 36