SlideShare a Scribd company logo
Cascading Style
Sheets
Taking control of you web pages
What we will learn today

 Why we use CSS
 Three ways to use CSS in an XHTML
 document
 How to write a style declaration
 How to target XHTML elements for styling
 How to change the style of that element
 How to style text
Why CSS?

 Separation of content from markup
 Cleaner code
 Easier to manage style changes
Why not Dreamweaver or
FrontPage?
 They produce messy code
 Don’t always do what you want
 Hard to troubleshoot problems
 You are NOT in control
What is CSS?

 A rule that defines a particular style that is
 applied to you XHTML markup
 A rule can define
    Font-size of the text of paragraphs
    Thickness of a border around an image
    Position of a headline
    Color of a background
    Etc.
Three ways to style

 Inline Styles
 Embedded Styles
 Linked
Inline


<p style="font-size: 25pt; font-weight:
bold; font-style: italic; color: red;">By
adding inline CSS styling to this
paragraph, we can override the default
styles.</p>
Inline Styles

  Inline styles have a narrow scope
  Not much better than using ‘font’ tags
  for everything
  Should generally be AVOIDED
Embedded

<head>
<title>Inline Style Example</title>
<style type="text/css">
h1 {font-size: 2em; font-weight:bold;}
p { color:blue; }
</style>
</head>

<body>
     <h1>First level heading tag</h1>
     <p>Here is the blue paragraph to styled
by         the embedded stylesheet.</p>
</body>
</html>
Embedded

 Scope limited to the page
 Page styles win out over external
 style sheets, but they lose out to
 inline styles
Linked

<head>
<link rel="stylesheet" href="stylesheet.css"
type="text/css" media="screen" />
</head>
<body>
Linked

<head>
<style type=“text/css”>
@import url(stylesheet.css), media;
</style>
</head>
<body>
Linked

 Style sheet
 Separates our markup and styles
 Can be linked to multiple pages
 Make changes across an entire site
 Create different styles for print or
 handheld devices
Linked




         Embedded



                    Inline
Anatomy of a CSS rule



    Selector     Declaration


    p {color: red}

      Property      Value
Anatomy of a CSS rule



    Selector      Declaration


   h1 {font-size: 10px}

       Property             Value
Grouping declarations


p {color:red}
p {font-size:12px}
p {line-height:15px}

Multiple declarations can be contained within a rule
p {color:red; font-size:12px; line-height:15px;}
Grouping selectors

      h1 {color: blue; font-weight: bold;}
      h2 {color: blue; font-weight: bold;}
      h3 {color: blue; font-weight: bold;}


h1, h2, h3 {color: blue; font-weight: bold;}

h3 {font-style: italic;}
Contextual Selectors


     em {color: green;}

     p em {color: green;}

Descendent Selector


    em is a descendent of p
Contextual Selectors

Example
Contextual Selectors


  Child Selector

  p>em {color: green;}

Child Selector
IDWIMIE
It Doesn’t Work In Microsoft Internet Explorer
Classes and IDs

 Give us the ability to assign styles
 without regard for the document
 hierarchy
 example
Classes

 Can names can be used multiple
 times in a document
 Is represented in the selector by a
 period ‘.’
IDs

 An ID name can only be used ONCE
 in any html document
 Is represented in the selector by a
 hash ‘#’
 Otherwise work the same as a class
 Example
When to use Classes vs. IDs

 Try to used tag and descendent
 selectors as much as possible
 Use classes when you can’t use a
 tag/descendent, and you need to
 target multiple elements on a page
 IDs are typically used to target entire
 sections of a page, usually in a ‘div’
 tag.
Universal Selector

       Represents all elements

       * {color:green;}
Universal Selector


       p * em {font-weight: bold;}
Selector Summary

 Tag Selector
 Descendent Selector
 Class and ID Selectors
 Universal Selector
 Child Selector -- IDWIMIE
Rule Declarations

What can we change about the
element?
   Size
   Position
   Color
Values Types

Words
 {font-weight: bold;}

Numeric values
  {font-size: 12px}

Color Values
  {font-color: red}
Numeric Values

Absolute values
  Pixels – 10px
  Points – 10pt
  Inches – 10in
  Centimeters – 10cm
  Millimeters – 10mm
  Picas – 10pc
Numeric Values

Relative Values
  percentage – 10%
  em – 10em
  ex – 10x
Color Values

Hexadecimal
  #RRGGBB or #RGB

 {color: #ffffff} is white
 {color: #000000} is black
 {color: #00ff00} is green
 {color: #0000ff} is blue
Color Values
Styling Fonts

First rule of fonts in web design:

You can’t use the fonts you want.
Sorry.


Times, Arial, Verdana, Courier
Win XP and Mac OS X

Arial            Franklin Gothic   Tahoma
Arial Black      Georgia           Times New
                                   Roman
Arial Narrow     Impact           Trebuchet MS
Century Gothic   Monotype Corsiva Verdana

Comic Sans MS    Palatino          Webdings
Courier New      Symbol
Serif vs. Sans-Serif

Serif:

Times New Roman
Sans-Serif:

Verdana
Monospace:

Courier New
Font-Family property



font-family { “trebuchet ms”, helvetica, arial,
sans-serif;}
Sizing fonts

Three types of values to size fonts:
  Absolute
     Pixels, inches, etc.
  Relative
     Percentages or ems
  Keywords
     x-small, small, large, x-large, etc.
Sizing with ems


body {font-family: verdana, arial, sans-
serif; font-size 100%;}
p {font-size: 1em;}
Font-Style

Font-style:
h2 {font-style: italic;}

Font-weight:
em {font-weight: bold;}

Font-Variant:
h2 {font-varient: small-caps;}
Font Property Shorthand

p {font-weight: bold; font-style: italic;
font-variant: small-caps; font-size: 1em;
font-family: verdana, arial sans-serif;}

p {font: bold italic small-caps 1em
verdana, arial sans-serif;}
Text properties

Line-height
p {line-height: 1.2;}
p {font: 1em/1.3; verdana, arial, sans-serif;}
Creates space between the lines of a block of text.


Text-align
h1 {text-align: center;}
p {text-align: justify;}
Sets overall spacing between words.



Text-indent
p {text-indent: 3em;}
Sets the start position of the text box in relation to its containing element
Text properties

Text-Decoration
.retailprice {text-decoration: strikethrough}
a:link {text-decoration: none}
Allows you to set a type of decoration to your text. Values include:
underline, overline, strikethrough, and blink.


Text-Transform
p.yelling {text-transform: capitalize;}
Changes capitalization of text within an element. Values include uppercase,
lowercase, capitalize, none.
Text properties

Letter-spacing
p {text-indent: 3em;}
Sets overall spacing between letter. Print typographers refer to this as
‘Tracking’


Word-Spacing
p {text-indent: 3em;}
Sets overall spacing between words.


Vertical-align
span.raised {font-size: .4em; vertical-align: 50%}
Moves type up or down with respect to the baseline.
Ad

More Related Content

What's hot (20)

Css selectors
Css selectorsCss selectors
Css selectors
Parth Trivedi
 
Java script errors &amp; exceptions handling
Java script  errors &amp; exceptions handlingJava script  errors &amp; exceptions handling
Java script errors &amp; exceptions handling
AbhishekMondal42
 
Css selectors
Css selectorsCss selectors
Css selectors
Dinesh Kumar
 
Css
CssCss
Css
Manav Prasad
 
Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)
Chris Poteet
 
CSS INHERITANCE
CSS INHERITANCECSS INHERITANCE
CSS INHERITANCE
Anuradha
 
CSS Dasar #7 : Selector
CSS Dasar #7 : SelectorCSS Dasar #7 : Selector
CSS Dasar #7 : Selector
Sandhika Galih
 
Types of Selectors (HTML)
Types of Selectors (HTML)Types of Selectors (HTML)
Types of Selectors (HTML)
Deanne Alcalde
 
Active server pages
Active server pagesActive server pages
Active server pages
mcatahir947
 
Introduction of Html/css/js
Introduction of Html/css/jsIntroduction of Html/css/js
Introduction of Html/css/js
Knoldus Inc.
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
Arulmurugan Rajaraman
 
Cascading Style Sheets (CSS) help
Cascading Style Sheets (CSS) helpCascading Style Sheets (CSS) help
Cascading Style Sheets (CSS) help
casestudyhelp
 
CSS Basics
CSS BasicsCSS Basics
CSS Basics
Sanjeev Kumar
 
An Overview of HTML, CSS & Java Script
An Overview of HTML, CSS & Java ScriptAn Overview of HTML, CSS & Java Script
An Overview of HTML, CSS & Java Script
Fahim Abdullah
 
XML
XMLXML
XML
baabtra.com - No. 1 supplier of quality freshers
 
CSS
CSS CSS
CSS
Sunil OS
 
PHP
PHPPHP
PHP
Steve Fort
 
C Structures And Unions
C  Structures And  UnionsC  Structures And  Unions
C Structures And Unions
Ram Sagar Mourya
 
Css properties
Css propertiesCss properties
Css properties
suresh_jathari
 

Similar to Introduction to CSS (20)

Web Design Course: CSS lecture 3
Web Design Course: CSS lecture 3Web Design Course: CSS lecture 3
Web Design Course: CSS lecture 3
Gheyath M. Othman
 
Introduction to CSS3
Introduction to CSS3Introduction to CSS3
Introduction to CSS3
Seble Nigussie
 
Presentation on CSS, Style Sheet, Types of Styles, Types of Text Formatting, ...
Presentation on CSS, Style Sheet, Types of Styles, Types of Text Formatting, ...Presentation on CSS, Style Sheet, Types of Styles, Types of Text Formatting, ...
Presentation on CSS, Style Sheet, Types of Styles, Types of Text Formatting, ...
SripathiRavi1
 
Cascading style-sheet-
Cascading style-sheet-Cascading style-sheet-
Cascading style-sheet-
Nimrakhan89
 
Web Engineering - Introduction to CSS
Web Engineering - Introduction to CSSWeb Engineering - Introduction to CSS
Web Engineering - Introduction to CSS
Nosheen Qamar
 
Unit 2-CSS & Bootstrap.ppt
Unit 2-CSS & Bootstrap.pptUnit 2-CSS & Bootstrap.ppt
Unit 2-CSS & Bootstrap.ppt
TusharTikia
 
Css
CssCss
Css
actacademy
 
Css
CssCss
Css
actacademy
 
CSS.pptx
CSS.pptxCSS.pptx
CSS.pptx
PushpaLatha551681
 
CSS Basic and Common Errors
CSS Basic and Common ErrorsCSS Basic and Common Errors
CSS Basic and Common Errors
Hock Leng PUAH
 
Css1
Css1Css1
Css1
Vadim Spiridenko
 
ch-hguygureehuvnvdfduyertiuhrnhduuyfjh3.pdf
ch-hguygureehuvnvdfduyertiuhrnhduuyfjh3.pdfch-hguygureehuvnvdfduyertiuhrnhduuyfjh3.pdf
ch-hguygureehuvnvdfduyertiuhrnhduuyfjh3.pdf
kasutaye192
 
CSS – CASCADING STYLE SHEET - MY_PPT.pptx
CSS – CASCADING STYLE SHEET - MY_PPT.pptxCSS – CASCADING STYLE SHEET - MY_PPT.pptx
CSS – CASCADING STYLE SHEET - MY_PPT.pptx
IorlahaSamuel1
 
CSS – CASCADING STYLE SHEET - MY_PPT.pptx
CSS – CASCADING STYLE SHEET - MY_PPT.pptxCSS – CASCADING STYLE SHEET - MY_PPT.pptx
CSS – CASCADING STYLE SHEET - MY_PPT.pptx
IorlahaSamuel1
 
Fundamental of Web Development Tutorials-CSS by PINFO Technologies.pptx
Fundamental of Web Development Tutorials-CSS by PINFO Technologies.pptxFundamental of Web Development Tutorials-CSS by PINFO Technologies.pptx
Fundamental of Web Development Tutorials-CSS by PINFO Technologies.pptx
umoren
 
Basics Of Css And Some Common Mistakes
Basics Of Css And Some Common MistakesBasics Of Css And Some Common Mistakes
Basics Of Css And Some Common Mistakes
sanjay2211
 
Unitegergergegegegetgegegegegegeg-2-CSS.pptx
Unitegergergegegegetgegegegegegeg-2-CSS.pptxUnitegergergegegegetgegegegegegeg-2-CSS.pptx
Unitegergergegegegetgegegegegegeg-2-CSS.pptx
VikasTuwar1
 
css1.ppt
css1.pptcss1.ppt
css1.ppt
BalasundaramSr
 
waxaada canshuurahaiyosiyaaddaguudeexamarwaaardaydaDAALBADAN.ppt
waxaada canshuurahaiyosiyaaddaguudeexamarwaaardaydaDAALBADAN.pptwaxaada canshuurahaiyosiyaaddaguudeexamarwaaardaydaDAALBADAN.ppt
waxaada canshuurahaiyosiyaaddaguudeexamarwaaardaydaDAALBADAN.ppt
Ismaciil2
 
CSS
CSSCSS
CSS
People Strategists
 
Web Design Course: CSS lecture 3
Web Design Course: CSS lecture 3Web Design Course: CSS lecture 3
Web Design Course: CSS lecture 3
Gheyath M. Othman
 
Presentation on CSS, Style Sheet, Types of Styles, Types of Text Formatting, ...
Presentation on CSS, Style Sheet, Types of Styles, Types of Text Formatting, ...Presentation on CSS, Style Sheet, Types of Styles, Types of Text Formatting, ...
Presentation on CSS, Style Sheet, Types of Styles, Types of Text Formatting, ...
SripathiRavi1
 
Cascading style-sheet-
Cascading style-sheet-Cascading style-sheet-
Cascading style-sheet-
Nimrakhan89
 
Web Engineering - Introduction to CSS
Web Engineering - Introduction to CSSWeb Engineering - Introduction to CSS
Web Engineering - Introduction to CSS
Nosheen Qamar
 
Unit 2-CSS & Bootstrap.ppt
Unit 2-CSS & Bootstrap.pptUnit 2-CSS & Bootstrap.ppt
Unit 2-CSS & Bootstrap.ppt
TusharTikia
 
CSS Basic and Common Errors
CSS Basic and Common ErrorsCSS Basic and Common Errors
CSS Basic and Common Errors
Hock Leng PUAH
 
ch-hguygureehuvnvdfduyertiuhrnhduuyfjh3.pdf
ch-hguygureehuvnvdfduyertiuhrnhduuyfjh3.pdfch-hguygureehuvnvdfduyertiuhrnhduuyfjh3.pdf
ch-hguygureehuvnvdfduyertiuhrnhduuyfjh3.pdf
kasutaye192
 
CSS – CASCADING STYLE SHEET - MY_PPT.pptx
CSS – CASCADING STYLE SHEET - MY_PPT.pptxCSS – CASCADING STYLE SHEET - MY_PPT.pptx
CSS – CASCADING STYLE SHEET - MY_PPT.pptx
IorlahaSamuel1
 
CSS – CASCADING STYLE SHEET - MY_PPT.pptx
CSS – CASCADING STYLE SHEET - MY_PPT.pptxCSS – CASCADING STYLE SHEET - MY_PPT.pptx
CSS – CASCADING STYLE SHEET - MY_PPT.pptx
IorlahaSamuel1
 
Fundamental of Web Development Tutorials-CSS by PINFO Technologies.pptx
Fundamental of Web Development Tutorials-CSS by PINFO Technologies.pptxFundamental of Web Development Tutorials-CSS by PINFO Technologies.pptx
Fundamental of Web Development Tutorials-CSS by PINFO Technologies.pptx
umoren
 
Basics Of Css And Some Common Mistakes
Basics Of Css And Some Common MistakesBasics Of Css And Some Common Mistakes
Basics Of Css And Some Common Mistakes
sanjay2211
 
Unitegergergegegegetgegegegegegeg-2-CSS.pptx
Unitegergergegegegetgegegegegegeg-2-CSS.pptxUnitegergergegegegetgegegegegegeg-2-CSS.pptx
Unitegergergegegegetgegegegegegeg-2-CSS.pptx
VikasTuwar1
 
waxaada canshuurahaiyosiyaaddaguudeexamarwaaardaydaDAALBADAN.ppt
waxaada canshuurahaiyosiyaaddaguudeexamarwaaardaydaDAALBADAN.pptwaxaada canshuurahaiyosiyaaddaguudeexamarwaaardaydaDAALBADAN.ppt
waxaada canshuurahaiyosiyaaddaguudeexamarwaaardaydaDAALBADAN.ppt
Ismaciil2
 
Ad

Recently uploaded (20)

Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptxTop 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
mkubeusa
 
Dark Dynamism: drones, dark factories and deurbanization
Dark Dynamism: drones, dark factories and deurbanizationDark Dynamism: drones, dark factories and deurbanization
Dark Dynamism: drones, dark factories and deurbanization
Jakub Šimek
 
fennec fox optimization algorithm for optimal solution
fennec fox optimization algorithm for optimal solutionfennec fox optimization algorithm for optimal solution
fennec fox optimization algorithm for optimal solution
shallal2
 
Artificial_Intelligence_in_Everyday_Life.pptx
Artificial_Intelligence_in_Everyday_Life.pptxArtificial_Intelligence_in_Everyday_Life.pptx
Artificial_Intelligence_in_Everyday_Life.pptx
03ANMOLCHAURASIYA
 
machines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdfmachines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdf
AmirStern2
 
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier VroomAI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
UXPA Boston
 
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Markus Eisele
 
Viam product demo_ Deploying and scaling AI with hardware.pdf
Viam product demo_ Deploying and scaling AI with hardware.pdfViam product demo_ Deploying and scaling AI with hardware.pdf
Viam product demo_ Deploying and scaling AI with hardware.pdf
camilalamoratta
 
Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)
Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)
Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)
CSUC - Consorci de Serveis Universitaris de Catalunya
 
IT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information TechnologyIT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information Technology
SHEHABALYAMANI
 
Config 2025 presentation recap covering both days
Config 2025 presentation recap covering both daysConfig 2025 presentation recap covering both days
Config 2025 presentation recap covering both days
TrishAntoni1
 
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
James Anderson
 
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptxReimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
John Moore
 
Q1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor PresentationQ1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor Presentation
Dropbox
 
An Overview of Salesforce Health Cloud & How is it Transforming Patient Care
An Overview of Salesforce Health Cloud & How is it Transforming Patient CareAn Overview of Salesforce Health Cloud & How is it Transforming Patient Care
An Overview of Salesforce Health Cloud & How is it Transforming Patient Care
Cyntexa
 
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
João Esperancinha
 
Agentic Automation - Delhi UiPath Community Meetup
Agentic Automation - Delhi UiPath Community MeetupAgentic Automation - Delhi UiPath Community Meetup
Agentic Automation - Delhi UiPath Community Meetup
Manoj Batra (1600 + Connections)
 
AI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamsonAI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamson
UXPA Boston
 
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
Lorenzo Miniero
 
Mastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B LandscapeMastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B Landscape
marketing943205
 
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptxTop 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
mkubeusa
 
Dark Dynamism: drones, dark factories and deurbanization
Dark Dynamism: drones, dark factories and deurbanizationDark Dynamism: drones, dark factories and deurbanization
Dark Dynamism: drones, dark factories and deurbanization
Jakub Šimek
 
fennec fox optimization algorithm for optimal solution
fennec fox optimization algorithm for optimal solutionfennec fox optimization algorithm for optimal solution
fennec fox optimization algorithm for optimal solution
shallal2
 
Artificial_Intelligence_in_Everyday_Life.pptx
Artificial_Intelligence_in_Everyday_Life.pptxArtificial_Intelligence_in_Everyday_Life.pptx
Artificial_Intelligence_in_Everyday_Life.pptx
03ANMOLCHAURASIYA
 
machines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdfmachines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdf
AmirStern2
 
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier VroomAI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
UXPA Boston
 
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Markus Eisele
 
Viam product demo_ Deploying and scaling AI with hardware.pdf
Viam product demo_ Deploying and scaling AI with hardware.pdfViam product demo_ Deploying and scaling AI with hardware.pdf
Viam product demo_ Deploying and scaling AI with hardware.pdf
camilalamoratta
 
IT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information TechnologyIT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information Technology
SHEHABALYAMANI
 
Config 2025 presentation recap covering both days
Config 2025 presentation recap covering both daysConfig 2025 presentation recap covering both days
Config 2025 presentation recap covering both days
TrishAntoni1
 
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
James Anderson
 
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptxReimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
John Moore
 
Q1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor PresentationQ1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor Presentation
Dropbox
 
An Overview of Salesforce Health Cloud & How is it Transforming Patient Care
An Overview of Salesforce Health Cloud & How is it Transforming Patient CareAn Overview of Salesforce Health Cloud & How is it Transforming Patient Care
An Overview of Salesforce Health Cloud & How is it Transforming Patient Care
Cyntexa
 
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
João Esperancinha
 
AI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamsonAI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamson
UXPA Boston
 
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
Lorenzo Miniero
 
Mastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B LandscapeMastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B Landscape
marketing943205
 
Ad

Introduction to CSS

  • 2. What we will learn today Why we use CSS Three ways to use CSS in an XHTML document How to write a style declaration How to target XHTML elements for styling How to change the style of that element How to style text
  • 3. Why CSS? Separation of content from markup Cleaner code Easier to manage style changes
  • 4. Why not Dreamweaver or FrontPage? They produce messy code Don’t always do what you want Hard to troubleshoot problems You are NOT in control
  • 5. What is CSS? A rule that defines a particular style that is applied to you XHTML markup A rule can define Font-size of the text of paragraphs Thickness of a border around an image Position of a headline Color of a background Etc.
  • 6. Three ways to style Inline Styles Embedded Styles Linked
  • 7. Inline <p style="font-size: 25pt; font-weight: bold; font-style: italic; color: red;">By adding inline CSS styling to this paragraph, we can override the default styles.</p>
  • 8. Inline Styles Inline styles have a narrow scope Not much better than using ‘font’ tags for everything Should generally be AVOIDED
  • 9. Embedded <head> <title>Inline Style Example</title> <style type="text/css"> h1 {font-size: 2em; font-weight:bold;} p { color:blue; } </style> </head> <body> <h1>First level heading tag</h1> <p>Here is the blue paragraph to styled by the embedded stylesheet.</p> </body> </html>
  • 10. Embedded Scope limited to the page Page styles win out over external style sheets, but they lose out to inline styles
  • 13. Linked Style sheet Separates our markup and styles Can be linked to multiple pages Make changes across an entire site Create different styles for print or handheld devices
  • 14. Linked Embedded Inline
  • 15. Anatomy of a CSS rule Selector Declaration p {color: red} Property Value
  • 16. Anatomy of a CSS rule Selector Declaration h1 {font-size: 10px} Property Value
  • 17. Grouping declarations p {color:red} p {font-size:12px} p {line-height:15px} Multiple declarations can be contained within a rule p {color:red; font-size:12px; line-height:15px;}
  • 18. Grouping selectors h1 {color: blue; font-weight: bold;} h2 {color: blue; font-weight: bold;} h3 {color: blue; font-weight: bold;} h1, h2, h3 {color: blue; font-weight: bold;} h3 {font-style: italic;}
  • 19. Contextual Selectors em {color: green;} p em {color: green;} Descendent Selector em is a descendent of p
  • 21. Contextual Selectors Child Selector p>em {color: green;} Child Selector
  • 22. IDWIMIE It Doesn’t Work In Microsoft Internet Explorer
  • 23. Classes and IDs Give us the ability to assign styles without regard for the document hierarchy example
  • 24. Classes Can names can be used multiple times in a document Is represented in the selector by a period ‘.’
  • 25. IDs An ID name can only be used ONCE in any html document Is represented in the selector by a hash ‘#’ Otherwise work the same as a class Example
  • 26. When to use Classes vs. IDs Try to used tag and descendent selectors as much as possible Use classes when you can’t use a tag/descendent, and you need to target multiple elements on a page IDs are typically used to target entire sections of a page, usually in a ‘div’ tag.
  • 27. Universal Selector Represents all elements * {color:green;} Universal Selector p * em {font-weight: bold;}
  • 28. Selector Summary Tag Selector Descendent Selector Class and ID Selectors Universal Selector Child Selector -- IDWIMIE
  • 29. Rule Declarations What can we change about the element? Size Position Color
  • 30. Values Types Words {font-weight: bold;} Numeric values {font-size: 12px} Color Values {font-color: red}
  • 31. Numeric Values Absolute values Pixels – 10px Points – 10pt Inches – 10in Centimeters – 10cm Millimeters – 10mm Picas – 10pc
  • 32. Numeric Values Relative Values percentage – 10% em – 10em ex – 10x
  • 33. Color Values Hexadecimal #RRGGBB or #RGB {color: #ffffff} is white {color: #000000} is black {color: #00ff00} is green {color: #0000ff} is blue
  • 35. Styling Fonts First rule of fonts in web design: You can’t use the fonts you want. Sorry. Times, Arial, Verdana, Courier
  • 36. Win XP and Mac OS X Arial Franklin Gothic Tahoma Arial Black Georgia Times New Roman Arial Narrow Impact Trebuchet MS Century Gothic Monotype Corsiva Verdana Comic Sans MS Palatino Webdings Courier New Symbol
  • 37. Serif vs. Sans-Serif Serif: Times New Roman Sans-Serif: Verdana Monospace: Courier New
  • 38. Font-Family property font-family { “trebuchet ms”, helvetica, arial, sans-serif;}
  • 39. Sizing fonts Three types of values to size fonts: Absolute Pixels, inches, etc. Relative Percentages or ems Keywords x-small, small, large, x-large, etc.
  • 40. Sizing with ems body {font-family: verdana, arial, sans- serif; font-size 100%;} p {font-size: 1em;}
  • 41. Font-Style Font-style: h2 {font-style: italic;} Font-weight: em {font-weight: bold;} Font-Variant: h2 {font-varient: small-caps;}
  • 42. Font Property Shorthand p {font-weight: bold; font-style: italic; font-variant: small-caps; font-size: 1em; font-family: verdana, arial sans-serif;} p {font: bold italic small-caps 1em verdana, arial sans-serif;}
  • 43. Text properties Line-height p {line-height: 1.2;} p {font: 1em/1.3; verdana, arial, sans-serif;} Creates space between the lines of a block of text. Text-align h1 {text-align: center;} p {text-align: justify;} Sets overall spacing between words. Text-indent p {text-indent: 3em;} Sets the start position of the text box in relation to its containing element
  • 44. Text properties Text-Decoration .retailprice {text-decoration: strikethrough} a:link {text-decoration: none} Allows you to set a type of decoration to your text. Values include: underline, overline, strikethrough, and blink. Text-Transform p.yelling {text-transform: capitalize;} Changes capitalization of text within an element. Values include uppercase, lowercase, capitalize, none.
  • 45. Text properties Letter-spacing p {text-indent: 3em;} Sets overall spacing between letter. Print typographers refer to this as ‘Tracking’ Word-Spacing p {text-indent: 3em;} Sets overall spacing between words. Vertical-align span.raised {font-size: .4em; vertical-align: 50%} Moves type up or down with respect to the baseline.
  翻译: