SlideShare a Scribd company logo
INTERNET
PROGRAMMING
CSS3
Cascading Style Sheet
Cascading Style Sheets
• allows you to specify the presentation of elements on a web page
(e.g., fonts, spacing, sizes, colors, positioning) separately from the
document’s structure and content (section headers, body text, links,
etc.).
• simplifies maintaining and modifying web pages, especially on large-
scale websites.
Inline Styles
• We can declare document styles
inline in the HTML5 markup, in
embedded style sheets or in
separate CSS files.
• inline styles declare an individual
element’s format using theHTML5
attribute style.
• Inline styles override any other
styles applied.
• Line 20 specifies the two
properties, font-size and color,
separated by a semicolon.
• Figure 4.2 contains the HTML
standard color set.
Embedded Style Sheets
• A second technique for using style sheets is embedded style sheets.
• enable you to embed a CSS3 document in an HTML5 document’s head
section.
The style Element and MIME Types
• The style element defines the embedded style sheet.
• Styles placed in the head apply to matching elements wherever they
appear in the body.
• The style element’s type attribute specifies the MIME (Multipurpose
Internet Mail Extensions) type that describes the style element’s content.
• Figure 4.4 lists some common MIME types used.
• first rule begins with the selector em, which selects all em elements
in the document.
• An em element indicates that its contents should be emphasized.
• Browsers usually render em elements in an italic font.
• Each rule’s body is enclosed in curly braces ({ and }).
• The property name is followed by a colon (:) and the property value.
Multiple properties are separated by semicolons (;).
• The font-weight property possible values are bold, normal (the
default), bolder (bolder than bold text) and lighter (lighter than
normal text).
Style Classes
• Line 17 declares a selector for a style class named special.
• Style-class declarations are preceded by a period (.).
font-family Property
• The font-family property (line 14) specifies the name of the font to
use.
• CSS allows you to specify a comma-separated list of fonts to use for a
particular style.
font-size Property
• Property font-size (line 15) specifies a 12-point font.
• Generally, relative font-size values are preferred over points, because
an author does not know the specific measurements of each client’s
display.
• Relative values permit more flexible viewing of web pages.
• A user may view a web page on a handheld device with a small
screen.
Applying a Style Class
• Line 22 uses the HTML5 attribute class in an h1 element to apply a
style class.
• When the browser renders the h1 element, the text appears on
screen with the properties of both an h1 element and the .special
style class applied.
Linking External Style Sheets
• With external style sheets (i.e., separate documents that contain only
CSS rules), you can provide a uniform look and feel to an entire website
(or to a portion of one).
• You can also reuse the same external style sheet across multiple
websites.
• Different pages on a site can all use the same style sheet.
• When changes to the styles are required, you need to modify only a
single CSS file to make style changes across all the pages that use those
styles. This concept is sometimes known as skinning.
Positioning Elements: Absolute Positioning, z-index
• Before CSS, controlling element positioning in HTML documents was
difficult—the browser determined positioning.
• CSS introduced the position property and a capability called absolute
positioning, which gives you greater control over how document
elements are displayed.
• The z-index property allows you
to layer overlapping elements.
• Elements that have higher z-
index values are displayed in
front of elements with lower z-
index values.
• If you do not specify a z-index or
if elements have the same z-
index value, the elements are
placed from background to
foreground in the order in which
they’re encountered in the
document.
• The default z-index value is 0.
Positioning Elements: Relative Positioning, span
• Setting the position property to relative, as in class super (lines 15–
16), lays out the element on the page and offsets it by the specified
top, bottom, left or right value.
• Class super (lines 15–16) lays out the text at the end of the sentence
as superscript and Class sub (lines 17–18) lays out the text as
subscript relative to the other text.
• Class shiftleft (lines 19–20) shifts the text at the end of the sentence
left and Class shiftright (lines 21–22) shifts the text right.
• The span’s height determines how much vertical space it will occupy.
• The font-size determines the size of the text inside the span.
• Element span is a grouping element—by default, it does not apply
any formatting to its contents. Its primary purpose is to apply CSS
rules or id attributes to a section of text.
• Element span is an inline-level element—it does not change the flow
of elements in the document.
• Examples of inline elements include span, img, a, em and strong.
Backgrounds
• CSS provides control over the
backgrounds of block-level elements.
• CSS can set a background color or add
background images to HTML5
elements.
• Figure 4.11 adds a corporate logo to
the bottom-right corner of the
document.
• This logo stays fixed in the corner even
when the user scrolls up or down the
screen.
background-image Property
• specifies the image URL for the image logo.png in the format url(fileLocation).
background-position Property
• places the image on the page.
• The keywords top, bottom, center, left and right are used individually or in
combination for vertical and horizontal positioning.
background-repeat Property
• controls background image tiling, which places multiple copies of the image
next to each other to fill the background.
• Other values include
• repeat (the default) to tile the image vertically and horizontally, repeat-x to
tile the
• image only horizontally or repeat-y to tile the image only vertically.
background-attachment: fixed Property
• background-attachment: fixed , fixes the image in the position
specified by background-position.
• Scrolling the browser window will not move the image from its
position. Default value is scroll.
font-style property
• to indent the first line of text in the element by a specified amount, in
this case 1em.
text-indent property
• allows you to set text to none, italic or oblique
Element Dimensions
• CSS rules can specify the actual dimensions of each page element.
• Specifying the width and height of an Element
 width of an element on screen should occupy 20 percent of the screen width.
 The height of an element can be set similarly, using the height property.
 This works only for block-level elements.
• text-align Property
 Most elements are left-aligned by default, but this alignment can be altered.
 values for the text-align property include center-aligned, left and right.
• overflow Property and Scroll Bars
 One problem with setting both dimensions of an element is that the content
inside the element can exceed the set boundaries.
 we set the overflow property to scroll, a setting that adds scroll bars if the text
overflows the boundaries.
Box Model and Text Flow
• All block-level HTML5 elements have a virtual box drawn around
them, based on what is known as the box model.
• When the browser renders an element using the box model, the
content is surrounded by padding, a border and a margin (Fig. 4.13).
• CSS controls the border using three properties: border-width, border-
color and border-style.
• The border-width property may be set to any valid CSS length (e.g.,
em, ex, px) or to the predefined value of thin, medium or thick.
• The border-color property sets the color.
• The border-style options are none, hidden, dotted, dashed, solid,
double, groove, ridge, inset and outset.
Drop-Down Menus
• Drop-down menus are a good way to provide navigation links without
using a lot of screen space.
• The :hover pseudo-class used to change a link’s style when the mouse
hovers over it.
• The display property allows you to decide whether an element is
rendered on the page or not.
• Possible values include block, inline and none.
• The block and inline values display the element as a block element or
an inline element, while none stops the element from being
rendered.
Text Shadows
• The CSS3 text-shadow property has four values: -4px, 4px, 6px and
DimGrey, which represent:
 Horizontal offset of the shadow—the number of pixels that the text-shadow
will appear to the left or the right of the text. A negative value moves the text-
shadow to the left; a positive value moves it to the right.
 Vertical offset of the shadow—the number of pixels that the text-shadow will be
shifted up or down from the text. A negative value moves the shadow up,
whereas a positive value moves it down.
 blur radius—the blur (in pixels) of the shadow. A blur-radius of 0px would
result in a shadow with a sharp edge (no blur). The greater the value, the
greater the blurring of the edges.
 color—determines the color of the text-shadow.
Rounded Corners
• allows you to add rounded corners to an element.
• Solid Navy borders adds slightly rounded corners to the rectangle.
• We increase the border-radius to 50px, making the left and right sides
completely round.
• We can also specify the radius for each corner with border-top-left-
radius, border-top-right-radius, border-bottom- left-radius and
border-bottom-right-radius.
Color
• CSS3 allows you to express color in several ways in addition to
standard color names (such as Aqua) or hexadecimal RGB values
(such as #00FFFF for Aqua).
• RGB (Red, Green, Blue) or RGBA (Red, Green, Blue, Alpha) gives you
greater control over the exact colors in your web pages.
• The value for each color—red, green and blue—can range from 0 to
255.
• The alpha value—which represents opacity—can be any value in the
range 0.0 (fully transparent) through 1.0 (fully opaque).
background: rgba(255, 0, 0, 0.5);
• CSS3 also allows you to express color using HSL (hue, saturation,
lightness) or HSLA (hue, saturation, lightness, alpha) values.
• The hue is a color or shade expressed as a value from 0 to 359
representing the degrees on a color wheel (a wheel is 360 degrees).
• The colors on the wheel progress in the order of the colors of the
rainbow—red, orange, yellow, green, blue, indigo and violet.
• The saturation— the intensity of the hue—is expressed as a
percentage, where 100% is fully saturated (the full color) and 0% is
gray.
• Lightness—the intensity of light or luminance of the hue— is also
expressed as a percentage.
background: hsla(0, 100%, 50%, 0.5);
• The resulting color would be a half-opaque red.

More Related Content

Similar to css3.pptx

Intro to html, css & sass
Intro to html, css & sassIntro to html, css & sass
Intro to html, css & sass
Sean Wolfe
 
Journey To The Front End World - Part2 - The Cosmetic
Journey To The Front End World - Part2 - The  CosmeticJourney To The Front End World - Part2 - The  Cosmetic
Journey To The Front End World - Part2 - The Cosmetic
Irfan Maulana
 
Css
CssCss
Unit-3-CSS-BWT.pptx
Unit-3-CSS-BWT.pptxUnit-3-CSS-BWT.pptx
Unit-3-CSS-BWT.pptx
Tanu524249
 
CSS tutorial chapter 1
CSS tutorial chapter 1CSS tutorial chapter 1
CSS tutorial chapter 1
jeweltutin
 
CSS Basics part One
CSS Basics part OneCSS Basics part One
CSS Basics part One
M Ashraful Islam Jewel
 
CSS for basic learner
CSS for basic learnerCSS for basic learner
CSS for basic learner
Yoeung Vibol
 
CSS Introduction
CSS Introduction CSS Introduction
CSS Introduction
Thapar Institute
 
basic programming language AND HTML CSS JAVApdf
basic programming language AND HTML CSS JAVApdfbasic programming language AND HTML CSS JAVApdf
basic programming language AND HTML CSS JAVApdf
elayelily
 
CascadingStyleSheets in ONESHOT By DeathCodeYT .pdf
CascadingStyleSheets  in ONESHOT By DeathCodeYT .pdfCascadingStyleSheets  in ONESHOT By DeathCodeYT .pdf
CascadingStyleSheets in ONESHOT By DeathCodeYT .pdf
balbirnainnain496
 
Understanding CSS for web development by software outsourcing company india
Understanding CSS for web development by software outsourcing company indiaUnderstanding CSS for web development by software outsourcing company india
Understanding CSS for web development by software outsourcing company india
Jignesh Aakoliya
 
CSS3 basics for beginners - Imrokraft
CSS3 basics for beginners - ImrokraftCSS3 basics for beginners - Imrokraft
CSS3 basics for beginners - Imrokraft
imrokraft
 
CSS
CSSCSS
WEB TECHNOLOGY Unit-2.pptx
WEB TECHNOLOGY Unit-2.pptxWEB TECHNOLOGY Unit-2.pptx
WEB TECHNOLOGY Unit-2.pptx
karthiksmart21
 
CSS
CSSCSS
Cascading style sheet
Cascading style sheetCascading style sheet
Cascading style sheet
Michael Jhon
 

Similar to css3.pptx (20)

Intro to html, css & sass
Intro to html, css & sassIntro to html, css & sass
Intro to html, css & sass
 
Journey To The Front End World - Part2 - The Cosmetic
Journey To The Front End World - Part2 - The  CosmeticJourney To The Front End World - Part2 - The  Cosmetic
Journey To The Front End World - Part2 - The Cosmetic
 
Css
CssCss
Css
 
CSS
CSSCSS
CSS
 
Unit-3-CSS-BWT.pptx
Unit-3-CSS-BWT.pptxUnit-3-CSS-BWT.pptx
Unit-3-CSS-BWT.pptx
 
CSS tutorial chapter 1
CSS tutorial chapter 1CSS tutorial chapter 1
CSS tutorial chapter 1
 
CSS Basics part One
CSS Basics part OneCSS Basics part One
CSS Basics part One
 
CSS for basic learner
CSS for basic learnerCSS for basic learner
CSS for basic learner
 
Introduction 2 css
Introduction 2 cssIntroduction 2 css
Introduction 2 css
 
CSS Introduction
CSS Introduction CSS Introduction
CSS Introduction
 
basic programming language AND HTML CSS JAVApdf
basic programming language AND HTML CSS JAVApdfbasic programming language AND HTML CSS JAVApdf
basic programming language AND HTML CSS JAVApdf
 
CascadingStyleSheets in ONESHOT By DeathCodeYT .pdf
CascadingStyleSheets  in ONESHOT By DeathCodeYT .pdfCascadingStyleSheets  in ONESHOT By DeathCodeYT .pdf
CascadingStyleSheets in ONESHOT By DeathCodeYT .pdf
 
Understanding CSS for web development by software outsourcing company india
Understanding CSS for web development by software outsourcing company indiaUnderstanding CSS for web development by software outsourcing company india
Understanding CSS for web development by software outsourcing company india
 
CSS3 basics for beginners - Imrokraft
CSS3 basics for beginners - ImrokraftCSS3 basics for beginners - Imrokraft
CSS3 basics for beginners - Imrokraft
 
CSS
CSSCSS
CSS
 
CSS
CSSCSS
CSS
 
WEB TECHNOLOGY Unit-2.pptx
WEB TECHNOLOGY Unit-2.pptxWEB TECHNOLOGY Unit-2.pptx
WEB TECHNOLOGY Unit-2.pptx
 
CSS
CSSCSS
CSS
 
Cascading style sheet
Cascading style sheetCascading style sheet
Cascading style sheet
 
Basic css
Basic cssBasic css
Basic css
 

Recently uploaded

Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 

Recently uploaded (20)

Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 

css3.pptx

  • 2. Cascading Style Sheets • allows you to specify the presentation of elements on a web page (e.g., fonts, spacing, sizes, colors, positioning) separately from the document’s structure and content (section headers, body text, links, etc.). • simplifies maintaining and modifying web pages, especially on large- scale websites.
  • 3. Inline Styles • We can declare document styles inline in the HTML5 markup, in embedded style sheets or in separate CSS files. • inline styles declare an individual element’s format using theHTML5 attribute style. • Inline styles override any other styles applied. • Line 20 specifies the two properties, font-size and color, separated by a semicolon. • Figure 4.2 contains the HTML standard color set.
  • 4.
  • 5. Embedded Style Sheets • A second technique for using style sheets is embedded style sheets. • enable you to embed a CSS3 document in an HTML5 document’s head section.
  • 6.
  • 7. The style Element and MIME Types • The style element defines the embedded style sheet. • Styles placed in the head apply to matching elements wherever they appear in the body. • The style element’s type attribute specifies the MIME (Multipurpose Internet Mail Extensions) type that describes the style element’s content. • Figure 4.4 lists some common MIME types used.
  • 8. • first rule begins with the selector em, which selects all em elements in the document. • An em element indicates that its contents should be emphasized. • Browsers usually render em elements in an italic font. • Each rule’s body is enclosed in curly braces ({ and }). • The property name is followed by a colon (:) and the property value. Multiple properties are separated by semicolons (;). • The font-weight property possible values are bold, normal (the default), bolder (bolder than bold text) and lighter (lighter than normal text).
  • 9. Style Classes • Line 17 declares a selector for a style class named special. • Style-class declarations are preceded by a period (.). font-family Property • The font-family property (line 14) specifies the name of the font to use. • CSS allows you to specify a comma-separated list of fonts to use for a particular style.
  • 10. font-size Property • Property font-size (line 15) specifies a 12-point font. • Generally, relative font-size values are preferred over points, because an author does not know the specific measurements of each client’s display. • Relative values permit more flexible viewing of web pages. • A user may view a web page on a handheld device with a small screen.
  • 11. Applying a Style Class • Line 22 uses the HTML5 attribute class in an h1 element to apply a style class. • When the browser renders the h1 element, the text appears on screen with the properties of both an h1 element and the .special style class applied.
  • 12. Linking External Style Sheets • With external style sheets (i.e., separate documents that contain only CSS rules), you can provide a uniform look and feel to an entire website (or to a portion of one). • You can also reuse the same external style sheet across multiple websites. • Different pages on a site can all use the same style sheet. • When changes to the styles are required, you need to modify only a single CSS file to make style changes across all the pages that use those styles. This concept is sometimes known as skinning.
  • 13.
  • 14. Positioning Elements: Absolute Positioning, z-index • Before CSS, controlling element positioning in HTML documents was difficult—the browser determined positioning. • CSS introduced the position property and a capability called absolute positioning, which gives you greater control over how document elements are displayed.
  • 15.
  • 16. • The z-index property allows you to layer overlapping elements. • Elements that have higher z- index values are displayed in front of elements with lower z- index values. • If you do not specify a z-index or if elements have the same z- index value, the elements are placed from background to foreground in the order in which they’re encountered in the document. • The default z-index value is 0.
  • 17. Positioning Elements: Relative Positioning, span • Setting the position property to relative, as in class super (lines 15– 16), lays out the element on the page and offsets it by the specified top, bottom, left or right value. • Class super (lines 15–16) lays out the text at the end of the sentence as superscript and Class sub (lines 17–18) lays out the text as subscript relative to the other text. • Class shiftleft (lines 19–20) shifts the text at the end of the sentence left and Class shiftright (lines 21–22) shifts the text right. • The span’s height determines how much vertical space it will occupy. • The font-size determines the size of the text inside the span.
  • 18.
  • 19. • Element span is a grouping element—by default, it does not apply any formatting to its contents. Its primary purpose is to apply CSS rules or id attributes to a section of text. • Element span is an inline-level element—it does not change the flow of elements in the document. • Examples of inline elements include span, img, a, em and strong.
  • 20. Backgrounds • CSS provides control over the backgrounds of block-level elements. • CSS can set a background color or add background images to HTML5 elements. • Figure 4.11 adds a corporate logo to the bottom-right corner of the document. • This logo stays fixed in the corner even when the user scrolls up or down the screen.
  • 21.
  • 22. background-image Property • specifies the image URL for the image logo.png in the format url(fileLocation). background-position Property • places the image on the page. • The keywords top, bottom, center, left and right are used individually or in combination for vertical and horizontal positioning. background-repeat Property • controls background image tiling, which places multiple copies of the image next to each other to fill the background. • Other values include • repeat (the default) to tile the image vertically and horizontally, repeat-x to tile the • image only horizontally or repeat-y to tile the image only vertically.
  • 23. background-attachment: fixed Property • background-attachment: fixed , fixes the image in the position specified by background-position. • Scrolling the browser window will not move the image from its position. Default value is scroll. font-style property • to indent the first line of text in the element by a specified amount, in this case 1em. text-indent property • allows you to set text to none, italic or oblique
  • 24. Element Dimensions • CSS rules can specify the actual dimensions of each page element. • Specifying the width and height of an Element  width of an element on screen should occupy 20 percent of the screen width.  The height of an element can be set similarly, using the height property.  This works only for block-level elements. • text-align Property  Most elements are left-aligned by default, but this alignment can be altered.  values for the text-align property include center-aligned, left and right. • overflow Property and Scroll Bars  One problem with setting both dimensions of an element is that the content inside the element can exceed the set boundaries.  we set the overflow property to scroll, a setting that adds scroll bars if the text overflows the boundaries.
  • 25.
  • 26. Box Model and Text Flow • All block-level HTML5 elements have a virtual box drawn around them, based on what is known as the box model. • When the browser renders an element using the box model, the content is surrounded by padding, a border and a margin (Fig. 4.13). • CSS controls the border using three properties: border-width, border- color and border-style.
  • 27.
  • 28. • The border-width property may be set to any valid CSS length (e.g., em, ex, px) or to the predefined value of thin, medium or thick. • The border-color property sets the color. • The border-style options are none, hidden, dotted, dashed, solid, double, groove, ridge, inset and outset.
  • 29. Drop-Down Menus • Drop-down menus are a good way to provide navigation links without using a lot of screen space. • The :hover pseudo-class used to change a link’s style when the mouse hovers over it. • The display property allows you to decide whether an element is rendered on the page or not. • Possible values include block, inline and none. • The block and inline values display the element as a block element or an inline element, while none stops the element from being rendered.
  • 30.
  • 31. Text Shadows • The CSS3 text-shadow property has four values: -4px, 4px, 6px and DimGrey, which represent:  Horizontal offset of the shadow—the number of pixels that the text-shadow will appear to the left or the right of the text. A negative value moves the text- shadow to the left; a positive value moves it to the right.  Vertical offset of the shadow—the number of pixels that the text-shadow will be shifted up or down from the text. A negative value moves the shadow up, whereas a positive value moves it down.  blur radius—the blur (in pixels) of the shadow. A blur-radius of 0px would result in a shadow with a sharp edge (no blur). The greater the value, the greater the blurring of the edges.  color—determines the color of the text-shadow.
  • 32.
  • 33. Rounded Corners • allows you to add rounded corners to an element. • Solid Navy borders adds slightly rounded corners to the rectangle. • We increase the border-radius to 50px, making the left and right sides completely round. • We can also specify the radius for each corner with border-top-left- radius, border-top-right-radius, border-bottom- left-radius and border-bottom-right-radius.
  • 34.
  • 35. Color • CSS3 allows you to express color in several ways in addition to standard color names (such as Aqua) or hexadecimal RGB values (such as #00FFFF for Aqua). • RGB (Red, Green, Blue) or RGBA (Red, Green, Blue, Alpha) gives you greater control over the exact colors in your web pages. • The value for each color—red, green and blue—can range from 0 to 255. • The alpha value—which represents opacity—can be any value in the range 0.0 (fully transparent) through 1.0 (fully opaque). background: rgba(255, 0, 0, 0.5); • CSS3 also allows you to express color using HSL (hue, saturation, lightness) or HSLA (hue, saturation, lightness, alpha) values. • The hue is a color or shade expressed as a value from 0 to 359 representing the degrees on a color wheel (a wheel is 360 degrees).
  • 36. • The colors on the wheel progress in the order of the colors of the rainbow—red, orange, yellow, green, blue, indigo and violet. • The saturation— the intensity of the hue—is expressed as a percentage, where 100% is fully saturated (the full color) and 0% is gray. • Lightness—the intensity of light or luminance of the hue— is also expressed as a percentage. background: hsla(0, 100%, 50%, 0.5); • The resulting color would be a half-opaque red.