SlideShare a Scribd company logo
1 of 16
JavaScript and CSS in
    HTML5 Web
    Development
   HTML5 Multimedia Developer’s Guide
             Chapter Two
              (Part Two)
Overview of CSS
Cascading Style Sheets (CSS) make Web
more manageable and design-friendly
Incorporated into Web page in 3 ways:
  From external CSS file
  From block of style instructions in
  <head>
  In-line as attribute of HTML tag
Why is it Cascading?
Priority of how 3 methods of CSS are used cascade
   Styling set on a tag overrides style found in
   head
   Styling found in head overrides style from
   external CSS file
   BUT: if CSS file is linked after styling in head,
   external file overrides styling found in head
So how does it work?
CSS works through system of selectors
  Selectors are identifiers that match page
  elements
Each selector has 1 or more declarations
  Declaration consists of a property and a
  value
An Example

p {border-style:solid;}
  Paragraph element (p) is selector
  border-style:solid is declaration
    Gives value solid to property
    border-style
Try this code:
<!doctype html>
<html lang=”en”>
   <head>
       <title>CSS Example 1</title>
   </head>
   <body>
       <p>I am text within a paragraph tag</p>
       I am another paragraph, but I do not sit in a
       paragraph tag. Therefore, I am not affected by
       CSS applied to paragraph tags.
       <p>I am another paragraph. My border is kinda
       neat, don’t ya think?</p>
   </body>
</html>
Now this...
<!doctype html>
<html lang=”en”>
     <head>
         <title>CSS Example 2</title>
         <style>
              p {border-style:solid;
                  padding:10px;
                  width:500px;}
         </style>
     </head>
     <body>
         <p>I am text within a paragraph tag</p>
         I am another paragraph, but I do not sit in a paragraph tag.
         Therefore, I am not affected by CSS applied to paragraph tags.
         <p>I am another paragraph. My border is kinda neat, don’t ya
         think?</p>
     </body>
</html>
Let’s look at cascading
<!doctype html>
<html lang=”en”>
     <head>
         <title>CSS Example 3</title>
         <link rel=”stylesheet” href=”style.css” type=”text/css” />
         <style>
              p {border-style:solid;padding:10px;width:500px;}
         </style>
     </head>
     <body>
         <p>I am text within a paragraph tag</p>
         I am another paragraph, but I do not sit in a paragraph tag.
         Therefore, I am not affected by CSS applied to paragraph tags.
         <p style=”font-style:normal;”>I am another paragraph. My border is
         kinda neat, don’t ya think?</p>
         <p style=”border-style:none;font-size:1em”>I am a paragraph, but
         (sigh) no border and small text</p>
     </body>
</html>
The style.css file

/*
This is a CSS external file
*/
p {
   font-size:2em;
   font-style:italic;
   }
ID Selectors
CSS can be applied to all visible HTML
tags
Can also target specific page areas using
identifiers
  Identifiers are set using the id attribute of
  the element. For example:
     <div id=”header”>
Playing With Identifiers



Type the code in Code Listings 2-7 and 2-8
CSS Classes vs. Identifiers

Identifiers apply CSS to one, unique page
element
Classes used to apply the same CSS to
multiple tags
Note: identifiers (in CSS) start with #.
Classes start with a period (.)
For Example...
.articletitle1 {font-
size:1.4em;}
.spacer1 (height:4px;}
Any page element with class of articletitle1
has a large font size
Any page element with class of spacer1 will
be 4px high
An Important Note


The # for identifiers and . for classes is used
only in CSS
When you set the id or class attribute, you
leave off the # or .
CSS and HTML5 Tags

How does CSS work with the new HTML5
tags?
  The same way!
  The new HTML5 tags are true HTML
  tags, so they’re treated the same as any
  other HTML tags.
Styling the Audio Tag
By default, the audio tag has little visual
impact
   Tag plays audio, and is aimed to and for
   the ears, not the eyes
Since it’s a native HTML5 tag, we can style
it
Code Listing 2-10

More Related Content

What's hot

Web programming css
Web programming cssWeb programming css
Web programming css
Uma mohan
 
Cascading Style Sheets
Cascading Style SheetsCascading Style Sheets
Cascading Style Sheets
Marc Steel
 

What's hot (19)

Css introduction
Css   introductionCss   introduction
Css introduction
 
Web programming css
Web programming cssWeb programming css
Web programming css
 
CSS - Cascading Style Sheet
CSS - Cascading Style SheetCSS - Cascading Style Sheet
CSS - Cascading Style Sheet
 
CSS- Cascading Style Sheet
CSS- Cascading Style SheetCSS- Cascading Style Sheet
CSS- Cascading Style Sheet
 
CSS introduction
CSS introductionCSS introduction
CSS introduction
 
CSS Introduction
CSS IntroductionCSS Introduction
CSS Introduction
 
HTML and CSS
HTML and CSSHTML and CSS
HTML and CSS
 
HTML- Hyper Text Markup Language
HTML- Hyper Text Markup LanguageHTML- Hyper Text Markup Language
HTML- Hyper Text Markup Language
 
Cascading Style Sheets
Cascading Style SheetsCascading Style Sheets
Cascading Style Sheets
 
Introduction to css & its attributes with syntax
Introduction to css & its attributes with syntaxIntroduction to css & its attributes with syntax
Introduction to css & its attributes with syntax
 
Casc Style Sheets Ii
Casc Style Sheets IiCasc Style Sheets Ii
Casc Style Sheets Ii
 
Cascading style sheets (CSS)
Cascading style sheets (CSS)Cascading style sheets (CSS)
Cascading style sheets (CSS)
 
Web Design Assignment 1
Web Design Assignment 1 Web Design Assignment 1
Web Design Assignment 1
 
CSS Basics - Stylesheets and Color
CSS Basics - Stylesheets and ColorCSS Basics - Stylesheets and Color
CSS Basics - Stylesheets and Color
 
CSS
CSSCSS
CSS
 
Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSS
 
Cascading Style Sheet
Cascading Style SheetCascading Style Sheet
Cascading Style Sheet
 
Week3 css
Week3 cssWeek3 css
Week3 css
 
Week 12 CSS - Review from last week
Week 12 CSS - Review from last weekWeek 12 CSS - Review from last week
Week 12 CSS - Review from last week
 

Viewers also liked

Castro Chapter 7
Castro Chapter 7Castro Chapter 7
Castro Chapter 7
Jeff Byrnes
 
Castro Chapter 3
Castro Chapter 3Castro Chapter 3
Castro Chapter 3
Jeff Byrnes
 
Financial analysis pp
Financial analysis ppFinancial analysis pp
Financial analysis pp
JoeVelarde
 
Castro Chapter 4
Castro Chapter 4Castro Chapter 4
Castro Chapter 4
Jeff Byrnes
 
Castro Chapter 5
Castro Chapter 5Castro Chapter 5
Castro Chapter 5
Jeff Byrnes
 
Castro Chapter 6
Castro Chapter 6Castro Chapter 6
Castro Chapter 6
Jeff Byrnes
 
Castro Chapter 15
Castro Chapter 15Castro Chapter 15
Castro Chapter 15
Jeff Byrnes
 
INFO 3775 Chapter 2 Part 1
INFO 3775 Chapter 2 Part 1INFO 3775 Chapter 2 Part 1
INFO 3775 Chapter 2 Part 1
Jeff Byrnes
 

Viewers also liked (8)

Castro Chapter 7
Castro Chapter 7Castro Chapter 7
Castro Chapter 7
 
Castro Chapter 3
Castro Chapter 3Castro Chapter 3
Castro Chapter 3
 
Financial analysis pp
Financial analysis ppFinancial analysis pp
Financial analysis pp
 
Castro Chapter 4
Castro Chapter 4Castro Chapter 4
Castro Chapter 4
 
Castro Chapter 5
Castro Chapter 5Castro Chapter 5
Castro Chapter 5
 
Castro Chapter 6
Castro Chapter 6Castro Chapter 6
Castro Chapter 6
 
Castro Chapter 15
Castro Chapter 15Castro Chapter 15
Castro Chapter 15
 
INFO 3775 Chapter 2 Part 1
INFO 3775 Chapter 2 Part 1INFO 3775 Chapter 2 Part 1
INFO 3775 Chapter 2 Part 1
 

Similar to INFO3775 Chapter 2 Part 2

Girl Develop It Cincinnati: Intro to HTML/CSS Class 2
Girl Develop It Cincinnati: Intro to HTML/CSS Class 2Girl Develop It Cincinnati: Intro to HTML/CSS Class 2
Girl Develop It Cincinnati: Intro to HTML/CSS Class 2
Erin M. Kidwell
 
CSS Cascading Style Sheet Introduction slides
CSS Cascading Style Sheet Introduction slidesCSS Cascading Style Sheet Introduction slides
CSS Cascading Style Sheet Introduction slides
Aasma13
 

Similar to INFO3775 Chapter 2 Part 2 (20)

Css
CssCss
Css
 
Unit 2-CSS & Bootstrap.ppt
Unit 2-CSS & Bootstrap.pptUnit 2-CSS & Bootstrap.ppt
Unit 2-CSS & Bootstrap.ppt
 
Introduction to CSS in HTML.ppt
Introduction to CSS in HTML.pptIntroduction to CSS in HTML.ppt
Introduction to CSS in HTML.ppt
 
Html Styles-CSS
Html Styles-CSSHtml Styles-CSS
Html Styles-CSS
 
INTRODUCTIONS OF CSS
INTRODUCTIONS OF CSSINTRODUCTIONS OF CSS
INTRODUCTIONS OF CSS
 
Girl Develop It Cincinnati: Intro to HTML/CSS Class 2
Girl Develop It Cincinnati: Intro to HTML/CSS Class 2Girl Develop It Cincinnati: Intro to HTML/CSS Class 2
Girl Develop It Cincinnati: Intro to HTML/CSS Class 2
 
IP - Lecture 6, 7 Chapter-3 (3).ppt
IP - Lecture 6, 7 Chapter-3 (3).pptIP - Lecture 6, 7 Chapter-3 (3).ppt
IP - Lecture 6, 7 Chapter-3 (3).ppt
 
DW_lesson2.ppt
DW_lesson2.pptDW_lesson2.ppt
DW_lesson2.ppt
 
CSS Cascading Style Sheet Introduction slides
CSS Cascading Style Sheet Introduction slidesCSS Cascading Style Sheet Introduction slides
CSS Cascading Style Sheet Introduction slides
 
DW_lesson2.ppt
DW_lesson2.pptDW_lesson2.ppt
DW_lesson2.ppt
 
DW_lesson2.ppt
DW_lesson2.pptDW_lesson2.ppt
DW_lesson2.ppt
 
DW_lesson2.ppt
DW_lesson2.pptDW_lesson2.ppt
DW_lesson2.ppt
 
DW_lesson2.ppt
DW_lesson2.pptDW_lesson2.ppt
DW_lesson2.ppt
 
Introduction to css
Introduction to cssIntroduction to css
Introduction to css
 
Lecture-6.pptx
Lecture-6.pptxLecture-6.pptx
Lecture-6.pptx
 
Css
CssCss
Css
 
Css
CssCss
Css
 
Introduction to css
Introduction to cssIntroduction to css
Introduction to css
 
CSS.pdf
CSS.pdfCSS.pdf
CSS.pdf
 
Cascstylesheets
CascstylesheetsCascstylesheets
Cascstylesheets
 

More from Jeff Byrnes

Castro Chapter 11
Castro Chapter 11Castro Chapter 11
Castro Chapter 11
Jeff Byrnes
 
Castro Chapter 10
Castro Chapter 10Castro Chapter 10
Castro Chapter 10
Jeff Byrnes
 
Castro Chapter 9
Castro Chapter 9Castro Chapter 9
Castro Chapter 9
Jeff Byrnes
 
Castro Chapter 8
Castro Chapter 8Castro Chapter 8
Castro Chapter 8
Jeff Byrnes
 
Castro Chapter 2
Castro Chapter 2Castro Chapter 2
Castro Chapter 2
Jeff Byrnes
 
Castro Chapter 2
Castro Chapter 2Castro Chapter 2
Castro Chapter 2
Jeff Byrnes
 

More from Jeff Byrnes (6)

Castro Chapter 11
Castro Chapter 11Castro Chapter 11
Castro Chapter 11
 
Castro Chapter 10
Castro Chapter 10Castro Chapter 10
Castro Chapter 10
 
Castro Chapter 9
Castro Chapter 9Castro Chapter 9
Castro Chapter 9
 
Castro Chapter 8
Castro Chapter 8Castro Chapter 8
Castro Chapter 8
 
Castro Chapter 2
Castro Chapter 2Castro Chapter 2
Castro Chapter 2
 
Castro Chapter 2
Castro Chapter 2Castro Chapter 2
Castro Chapter 2
 

Recently uploaded

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
 

Recently uploaded (20)

Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.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...
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Philosophy of china and it's charactistics
Philosophy of china and it's charactisticsPhilosophy of china and it's charactistics
Philosophy of china and it's charactistics
 
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
 
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
 
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.
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
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
 

INFO3775 Chapter 2 Part 2

  • 1. JavaScript and CSS in HTML5 Web Development HTML5 Multimedia Developer’s Guide Chapter Two (Part Two)
  • 2. Overview of CSS Cascading Style Sheets (CSS) make Web more manageable and design-friendly Incorporated into Web page in 3 ways: From external CSS file From block of style instructions in <head> In-line as attribute of HTML tag
  • 3. Why is it Cascading? Priority of how 3 methods of CSS are used cascade Styling set on a tag overrides style found in head Styling found in head overrides style from external CSS file BUT: if CSS file is linked after styling in head, external file overrides styling found in head
  • 4. So how does it work? CSS works through system of selectors Selectors are identifiers that match page elements Each selector has 1 or more declarations Declaration consists of a property and a value
  • 5. An Example p {border-style:solid;} Paragraph element (p) is selector border-style:solid is declaration Gives value solid to property border-style
  • 6. Try this code: <!doctype html> <html lang=”en”> <head> <title>CSS Example 1</title> </head> <body> <p>I am text within a paragraph tag</p> I am another paragraph, but I do not sit in a paragraph tag. Therefore, I am not affected by CSS applied to paragraph tags. <p>I am another paragraph. My border is kinda neat, don’t ya think?</p> </body> </html>
  • 7. Now this... <!doctype html> <html lang=”en”> <head> <title>CSS Example 2</title> <style> p {border-style:solid; padding:10px; width:500px;} </style> </head> <body> <p>I am text within a paragraph tag</p> I am another paragraph, but I do not sit in a paragraph tag. Therefore, I am not affected by CSS applied to paragraph tags. <p>I am another paragraph. My border is kinda neat, don’t ya think?</p> </body> </html>
  • 8. Let’s look at cascading <!doctype html> <html lang=”en”> <head> <title>CSS Example 3</title> <link rel=”stylesheet” href=”style.css” type=”text/css” /> <style> p {border-style:solid;padding:10px;width:500px;} </style> </head> <body> <p>I am text within a paragraph tag</p> I am another paragraph, but I do not sit in a paragraph tag. Therefore, I am not affected by CSS applied to paragraph tags. <p style=”font-style:normal;”>I am another paragraph. My border is kinda neat, don’t ya think?</p> <p style=”border-style:none;font-size:1em”>I am a paragraph, but (sigh) no border and small text</p> </body> </html>
  • 9. The style.css file /* This is a CSS external file */ p { font-size:2em; font-style:italic; }
  • 10. ID Selectors CSS can be applied to all visible HTML tags Can also target specific page areas using identifiers Identifiers are set using the id attribute of the element. For example: <div id=”header”>
  • 11. Playing With Identifiers Type the code in Code Listings 2-7 and 2-8
  • 12. CSS Classes vs. Identifiers Identifiers apply CSS to one, unique page element Classes used to apply the same CSS to multiple tags Note: identifiers (in CSS) start with #. Classes start with a period (.)
  • 13. For Example... .articletitle1 {font- size:1.4em;} .spacer1 (height:4px;} Any page element with class of articletitle1 has a large font size Any page element with class of spacer1 will be 4px high
  • 14. An Important Note The # for identifiers and . for classes is used only in CSS When you set the id or class attribute, you leave off the # or .
  • 15. CSS and HTML5 Tags How does CSS work with the new HTML5 tags? The same way! The new HTML5 tags are true HTML tags, so they’re treated the same as any other HTML tags.
  • 16. Styling the Audio Tag By default, the audio tag has little visual impact Tag plays audio, and is aimed to and for the ears, not the eyes Since it’s a native HTML5 tag, we can style it Code Listing 2-10