SlideShare a Scribd company logo
1
1 © 2001-2003 Marty Hall, Larry Brown http://www.corewebprogramming.com
Web
core
programming
Cascading
Style Sheets
Cascading Style Sheets2 www.corewebprogramming.com
Agenda
• Specifying style sheet rules
• External and inline style specifications
• Creating new HTML elements through style
sheet classes
• Specifying font and text properties
• Controlling foreground and background
properties
• Netscape LAYERs
• Creating layers through style sheets
2
Cascading Style Sheets3 www.corewebprogramming.com
Benefits of Cascading Style
Sheets
• Powerful and flexible way to specify the
formatting of HTML elements
– Can define font, size, background color, background
image, margins, etc.
• Share style sheets across multiple
documents or entire Web site
• Can specify a class definition for a style,
effectively defining new HTML elements
• Rules are applied in a hierarchical manner
(precedence rules)
Cascading Style Sheets4 www.corewebprogramming.com
Cascading Style Sheets
• CSS, Level 1 (1996)
– Concerned with applying simple styles to HTML elements
– http://www.w3.org/TR/REC-CSS1
• CSS, Level 2 (1998)
– Supports media-specific style sheets (visual browsers, aural devices,
printers, braille devices)
– http://www.w3.org/TR/REC-CSS2
• CSS, Level 3 (draft 2001)
– Focused on modularization of the CSS specification
– http://www.w3.org/TR/css3-roadmap/
• Note:
– CSS1 is supported by Netscape and Internet Explorer 4.x and above
– See http://www.webreview.com/style/css1/charts/mastergrid.shtml
for a summary of browser compatibility
3
Cascading Style Sheets5 www.corewebprogramming.com
Specifying Style Rules
• General form of rule
selector { property: value }
or
selector { property1: value1;
property2: value2;
...
propertyN: valueN }
• Example
H1 { text-align: center;
color: blue }
Cascading Style Sheets6 www.corewebprogramming.com
Fizzics1.html, Example
(no style sheet)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>New Advances in Physics</TITLE>
</HEAD>
<BODY>
<H1>New Advances in Physics</H1>
<H2>Turning Gold into Lead</H2>
In a startling breakthrough, scientist B.O. "Gus" Fizzics
has invented a <STRONG>practical</STRONG> technique for
transmutation! For more details, please see
<A HREF="give-us-your-gold.html">our transmutation thesis</A>.
...
</BODY>
</HTML>
4
Cascading Style Sheets7 www.corewebprogramming.com
Fizzics1.html, Result
(no style sheet)
Cascading Style Sheets8 www.corewebprogramming.com
Fizzics2.html, Example
(with style sheet)
• Style information
<HEAD>
<TITLE>Document Title</TITLE>
<STYLE TYPE="text/css">
<!--
BODY { background: URL(images/confetti-background.jpg) }
H1 { text-align: center;
font-family: Blackout }
H2 { font-family: MeppDisplayShadow }
STRONG { text-decoration: underline }
-->
</STYLE>
</HEAD>
5
Cascading Style Sheets9 www.corewebprogramming.com
Fizzics2.html, Result
(with style sheet)
Cascading Style Sheets10 www.corewebprogramming.com
External Style Sheets
• Specify link to external style sheet in the HEAD
section of the HTML document
<LINK REL=STYLESHEET
HREF="Sitestyle.css" // Absolute or relative link
TYPE="text/css">
• Sitestyle.css
/* Example of an external style sheet */
H1 { text-align: center;
font-family: Arial
}
H2 { color: #440000;
text-align: center;
font-family: Arial Black, Arial, Helvetica, sans-serif
}
...
6
Cascading Style Sheets11 www.corewebprogramming.com
Inline Style Specification
• Use the STYLE attribute defined for each
HTML element to directly specify the style
• Example
...
<H1>New Advances in Physics</H1>
<P STYLE="margin-left: 0.5in;
margin-right: 0.5in;
font-style: italic">
This paper gives the solution to three
previously unsolved problems: turning lead into gold,
antigravity, and a practical perpetual motion machine.
...
Cascading Style Sheets12 www.corewebprogramming.com
Defining Style Classes
• To define an element style class proceed
the HTML element by a period and class
name
// Define an "abstract" paragraph type
P.abstract { margin-left: 0.5in;
margin-right: 0.5in;
font-style: italic }
• To use, supply the name of the style class in
the CLASS attribute of the HTML element
<H1>New Advances in Physics</H1>
<P CLASS="abstract">
This paper gives the solution to three previously
unsolved problems: turning lead into gold,
antigravity, and a practical perpetual motion machine.
7
Cascading Style Sheets13 www.corewebprogramming.com
Defining Style Classes
• To define a global style class, omit the
element name
// Style available to all elements
.blue { color: blue; font-weight: bold }
• To use, simple specify the style class in the
CLASS attribute of the HTML element
<H2 CLASS="blue">A Blue Heading</H2>
<!-- Apply to a section of text -->
This text is in the default color, but
<SPAN CLASS="blue">this text is blue.</SPAN>
Cascading Style Sheets14 www.corewebprogramming.com
Defining Styles through
User-Defined IDs
• An ID is like a class but can be applied only
once in a document
<HEAD>
<TITLE>...</TITLE>
<STYLE TYPE="text/css">
<!--
#foo { color: red }
-->
</STYLE>
</HEAD>
<BODY>
...
<P ID="foo">
...
</BODY>
8
Cascading Style Sheets15 www.corewebprogramming.com
Style Sheet Precedence Rules
1. Rules marked “important” have the highest
priority (rarely used)
H1 { color: black !important;
font-family: sans-serif }
2. Author rules have precedence over reader
rules
• Style sheet rules override browser preferences
Cascading Style Sheets16 www.corewebprogramming.com
Style Sheet Precedence Rules,
cont.
3. More specific rules have precedence over
less specific rules
#foo { ... } // ID selector highest priority
P.big H1 { ... } // Class higher over element
P STRONG { ... } // Two tags higher than single tag
STRONG { ... }
4. In case of tie, the last rule has priority
9
Cascading Style Sheets17 www.corewebprogramming.com
Useful Font Properties
• font-weight
– Relative weight (boldness) of font
– normal | lighter | bold | bolder | 100 | 200 | ... | 900
H1 { font-weight : 200 }
H2 { font-weight : bolder }
• font-style
– Font face type within a family
– normal | italic | oblique
P { font-style : normal }
TH { font-sytle : italic }
Cascading Style Sheets18 www.corewebprogramming.com
Useful Font Properties, cont.
• font-size
– Either relative or absolute size of font
– pt, pc, in, cm, mm | em, ex, px, % |
xx-large | x-large | large | medium | small | x-small |
xx-small | smaller | larger
STRONG { font-size: 150% }
P { font-size: 14pt }
P { font-size: xx-large }
• font-family
– Typeface family for the font
H1 { font-family: Arial }
10
Cascading Style Sheets19 www.corewebprogramming.com
CampBearClaw.html, Example
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Camp Bear Claw</TITLE>
<LINK REL=STYLESHEET HREF="CampBearClaw.css" TYPE="text/css">
</HEAD>
<BODY>
<H1>Camp Bear Claw</H1>
We have the following activities:
<H2 CLASS="archery">Archery</H2>
<H2 CLASS="arts">Arts and Crafts</H2>
<H2 CLASS="horseback">Horseback Riding</H2>
<H2 CLASS="hiking">Hiking</H2>
<H2 CLASS="campfire">Campfire Song Times</H2>
<H2 CLASS="java">Java Programming</H2>
</BODY>
</HTML>
Cascading Style Sheets20 www.corewebprogramming.com
CampBearClaw.css
H1 { text-align: center;
font-family: Funstuff }
H2.archery { font-family: ArcheryDisplay }
H2.arts { font-family: ClampettsDisplay }
H2.horseback { font-family: Rodeo }
H2.hiking { font-family: SnowtopCaps }
H2.campfire { font-family: Music Hall }
H2.java { font-family: Digiface }
11
Cascading Style Sheets21 www.corewebprogramming.com
CampBearClaw.html, Result
Cascading Style Sheets22 www.corewebprogramming.com
Useful Text Properties
• text-decoration
– Describes text additions or “decorations” that are added
to the text of an element
– none | underline | overline | line-through | blink
P { text-decoration: underline }
• vertical-align
– Determines how elements are positioned vertically
– top | bottom | baseline | middle | sub | super | text-top |
text-bottom | %
• text-align
– Determines how paragraphs are positioned horizontally
– left | right | center | justify
12
Cascading Style Sheets23 www.corewebprogramming.com
Useful Text Properties, cont.
• text-indent
– Specifies the indentation of the first line of the paragraph
– +/– pt, pc, in, cm, mm | +/– em, ex, px, %
P { text-indent: -25px } /* Hanging indent */
• line-height
– Specifies the distance between two consecutive baselines
in a paragraph
– normal | number | pt, pc, in, cm, mm | em, ex, px, %
.double { line-height: 200% }
.triple { line-height: 3 } /* 3x the font size */
DIV { line-height: 1.5em }
Cascading Style Sheets24 www.corewebprogramming.com
Bates.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>An Open Letter to the IRS</TITLE>
<LINK REL=STYLESHEET HREF="Bates.css" TYPE="text/css">
</HEAD>
<BODY BACKGROUND="images/bond-paper.jpg">
<P CLASS="rhead">
April 1, 2001
<HR>
<P CLASS="rhead">
William A. Bates<BR>
Macrosoft Corporation<BR>
Blumond, WA 12345
<P CLASS="lhead">
Internal Revenue Service<BR>
Philadelphia, PA 67890
<P>
<BR>
Dear Sirs,
<P CLASS="body">
I am writing to inform you that, due to financial difficulties,
...
13
Cascading Style Sheets25 www.corewebprogramming.com
Bates.css
P { margin-top: 5px }
P.rhead { text-align: right;
margin-right: 0.5in;
font-family: sans-serif }
P.lhead { font-family: sans-serif }
P.body { text-align: justify;
text-indent: 0.5in }
P.foot { margin-left: 60%;
line-height: 300% }
Cascading Style Sheets26 www.corewebprogramming.com
Bates.html
14
Cascading Style Sheets27 www.corewebprogramming.com
Useful Foreground and
Background Properties
• color
– Color of the text or foreground color
– color-name | #RRGGBB | #RGB | rgb(rrr, ggg, bbb) |
rgb(rrr%, ggg%, bbb%)
P { color : blue }
H1 { color : #00AABB }
H3 { color : rgb(255, 0, 0 ) } /* red */
• background-image
– none | url(filename)
– Specifies an image to use as the background of region
H2 { background-image: url(Bluedrop.gif);}
Cascading Style Sheets28 www.corewebprogramming.com
Useful Foreground and
Background Properties, cont.
• background-repeat
– Specifies how to tile the image in the region
– repeat | repeat-x | repeat-y | norepeat
BODY {
background-image: url(Bluedot.gif);
background-repeat: repeat-x;
}
• background
– Lets you combine properties in a single entry
P { background: url(wallpaper.jpg) repeat-x }
15
Cascading Style Sheets29 www.corewebprogramming.com
Cabinets.html, Example
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Joe's Cabinets</TITLE>
<LINK REL=STYLESHEET HREF="Cabinets.css" TYPE="text/css">
</HEAD>
<BODY>
<CENTER>
<TABLE WIDTH=360 HEIGHT=199>
<TR><TD ALIGN="CENTER" CLASS="banner">Joe's Cabinets
</TABLE>
</CENTER>
<P>
Welcome to Joe's Cabinets. We specialize in
<UL>
<LI>Custom Cabinets
<LI>Kitchen Remodeling
<!-- Etc -->
</UL>
<!-- Etc -->
</BODY>
</HTML>
Cascading Style Sheets30 www.corewebprogramming.com
Cabinets.css
.banner { background: url(images/boards.jpg) repeat-x;
font-size: 50pt;
font-family: Arial Rounded MT Bold }
16
Cascading Style Sheets31 www.corewebprogramming.com
Cabinets.html, Result
Cascading Style Sheets32 www.corewebprogramming.com
Properties of the Bounding Box
• CSS assume that all elements result in one
or more rectangular regions (bounding box)
• Styles can specify the margins, borders,
and padding of the bounding box
P { margin: 0.25in;
border: 0.25in solid black;
padding: 0.25in;
background: URL(images/bond-paper.jpg) }
17
Cascading Style Sheets33 www.corewebprogramming.com
The Bounding Box
Cascading Style Sheets34 www.corewebprogramming.com
Images and Floating Elements
• width, height
– Specify a fixed size for an element (usually an image)
– auto | pt, pc, in, cm, mm | em, ex, px
IMG.bullet { width: 50px; height: 50px }
• float
– This property lets elements float into the left or right
margins where the text wrapping arounds
– none | left | right
18
Cascading Style Sheets35 www.corewebprogramming.com
Psalm23.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>The 23rd Psalm</TITLE>
<STYLE>
<!--
SPAN { float: left;
font-family: "Cushing Book";
font-size: 75pt }
-->
</STYLE>
</HEAD>
<BODY>
<H2 ALIGN="CENTER">
The 23rd Psalm (King James Version)</H2>
<SPAN>T</SPAN>he LORD is my shepherd; I shall not want.
He maketh me to lie down in green pastures: he leadeth me
beside the still waters. He restoreth my soul: he leadeth me
in the paths of righteousness for his name's sake. Yea,
Cascading Style Sheets36 www.corewebprogramming.com
Psalm23.html, Result
The float property can be used
to implement “drop caps”
19
Cascading Style Sheets37 www.corewebprogramming.com
Effect of Paragraph Breaks,
Example, cont.
Adding a <P> element simply
continues the flow
Adding <P STYLE="clear: left">
forces the next paragraph to start after
the floating element
Cascading Style Sheets38 www.corewebprogramming.com
Netscape Layers
• Layers (LAYER and ILAYER elements) allow
you to:
– Place HTML markup in separate regions
– Position each region on the page
• LAYER and ILAYER are only supported in
Netscape 4
– Layers are not supported in Internet Explorer or
Netscape 6
20
Cascading Style Sheets39 www.corewebprogramming.com
LAYER and ILAYER
• LAYER element
– The LAYER element creates regions that have an
absolute position with respect to the window or parent
layer
• ILAYER
– The ILAYER element creates inline layers (regions that
are embedded in the flow of the text)
Cascading Style Sheets40 www.corewebprogramming.com
LAYER, Example
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Using ABOVE and BELOW</TITLE>
</HEAD>
<BODY>
<H1>Using <CODE>ABOVE</CODE> and <CODE>BELOW</CODE></H1>
<LAYER ID="Top" LEFT=60 TOP=120
WIDTH=500 HEIGHT=100 BGCOLOR="#F5DEB3">
This layer is on top, even though it appears
first in the HTML document.
</LAYER>
<LAYER ID="Bottom" ABOVE="Top" LEFT=10 TOP=70
WIDTH=500 HEIGHT=100 BGCOLOR="gray">
This layer is on the bottom, even though it appears
second in the HTML document.
</LAYER>
</BODY>
</HTML>
21
Cascading Style Sheets41 www.corewebprogramming.com
LAYER, Result
Netscape 4 layers can specify the relative order of the layers.
Cascading Style Sheets42 www.corewebprogramming.com
ILAYER, Example
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Row, Row, Row Your Boat</TITLE>
</HEAD>
<BODY>
<IMG SRC="images/Rowboat.gif" ALIGN="RIGHT">
<HR>
<B>Row, Row, Row Your Boat</B><BR>
Row, row, row your boat<BR>
Gently
<ILAYER TOP=10>down</ILAYER>
<ILAYER TOP=20>the</ILAYER>
<ILAYER TOP=30>stream<BR>
Merrily, merrily, merrily, merrily<BR>
Life is but a dream<BR>
<HR>
</ILAYER>
</BODY>
</HTML>
22
Cascading Style Sheets43 www.corewebprogramming.com
ILAYER, Result
Using TOP in ILAYER can move text up or down in the
current paragraph.
Cascading Style Sheets44 www.corewebprogramming.com
Specifying Layers with Style
Sheets
• Style sheets provide an alternative to
LAYER and ILAYER elements
– Style sheet layers are supported by both Netscape and
Internet Explorer
– However, Netscape layers are more complete
• No equivalent style for PAGEX and PAGEY for
positioning
• Problem
– Netscape and IE use a different object model to refer to
layers
– See http://www.stopbadtherapy.com/standards.shtml for
creating cross-browser layers
23
Cascading Style Sheets45 www.corewebprogramming.com
Creating a Style Sheet Layer
• Use an ID tag format to define a style
#layer1 { position: absolute;
left: 50px; top: 75px;
... }
• Define the layer through a DIV or SPAN
element
<SPAN ID="layer1">
...
</SPAN>
<DIV ID="layer2">
...
</DIV>
Cascading Style Sheets46 www.corewebprogramming.com
Useful Layer Properties
• left, top
– Specifies the left and top sides of the layer relative to the
parent window
• position
– Describes how the position is defined to the parent
window
– absolute, relative, static
• visibility
– Determines whether a layer is visible or hidden
– visible, hidden, inherit
24
Cascading Style Sheets47 www.corewebprogramming.com
Dynamically Changing a
Layer’s Visibility, Example
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Changing Visibility Dynamically</TITLE>
<STYLE>
<!--
#layer1 { position: absolute; left: 0.25in; top: 1.5in;
color: black; background-color: #F5DEB3;
visibility: hidden }
#layer2 { position: absolute; left: 0.25in; top: 1.5in;
color: #F5DEB3; background-color: black;
visibility: hidden }
H1 { text-align: center;
font-family: Arial }
FORM { text-align: center }
-->
</STYLE>
...
Cascading Style Sheets48 www.corewebprogramming.com
Dynamically Changing a
Layer’s Visibility, Example
<SCRIPT TYPE="text/javascript">
<!--
function display(value1, value2){
if(document.layers) { // Test for Netscape.
document.layers.layer1.visibility = value1;
document.layers.layer2.visibility = value2;
} else {
document.all.layer1.style.visibility = value1;
document.all.layer2.style.visibility = value2;
}
}
//-->
</SCRIPT>
</HEAD>
<BODY BGCOLOR="WHITE">
<H1>Changing Visibility Dynamically</H1>
<FORM>
<INPUT TYPE="BUTTON" VALUE="Show Layer1"
onClick="display('visible', 'hidden')">
<INPUT TYPE="BUTTON" VALUE="Show Layer2"
onClick="display('hidden', 'visible')">
</FORM>
...
25
Cascading Style Sheets49 www.corewebprogramming.com
Dynamically Changing a
Layer’s Visibility, Example
...
<DIV ID="layer1">
<H1>This is layer1.</H1>
</DIV>
<DIV ID="layer2">
<H1>This is layer2.</H1>
</DIV>
</BODY>
</HTML>
Cascading Style Sheets50 www.corewebprogramming.com
Dynamically Changing a
Layer’s Visibility, Result
Selecting a button displays a hidden layer.
26
Cascading Style Sheets51 www.corewebprogramming.com
Appendix, Length Units
Unit Description
cm Centimeters (absolute unit)
em The height of the current font (relative unit)
ex The height of the letter “x” in the current font (relative unit)
in Inches (absolute unit)
mm Millimeters (absolute unit)
pc Picas; 6 picas per inch; 12 points per pica (absolute unit)
pt Points; 72 points per inch (absolute unit)
px Pixels (relative unit)
Cascading Style Sheets52 www.corewebprogramming.com
Summary
• Through style sheets you can specify the
general formatting of HTML elements
• Use external style sheets to share styles
across all documents in the Web site
• Class definitions allow you to define
multiple styles for an HTML element
• LAYERs are only supported by Netscape 5;
however, a viable alternative are style sheet
layers
27
53 © 2001-2003 Marty Hall, Larry Brown http://www.corewebprogramming.com
Web
core
programming
Questions?
Ad

More Related Content

What's hot (20)

Unit 2 (it workshop)
Unit 2 (it workshop)Unit 2 (it workshop)
Unit 2 (it workshop)
Dr.Lokesh Gagnani
 
Web Design Course: CSS lecture 2
Web Design Course: CSS  lecture 2Web Design Course: CSS  lecture 2
Web Design Course: CSS lecture 2
Gheyath M. Othman
 
CSS - OOCSS, SMACSS and more
CSS - OOCSS, SMACSS and moreCSS - OOCSS, SMACSS and more
CSS - OOCSS, SMACSS and more
Russ Weakley
 
Web Design Course: CSS lecture 5
Web Design Course: CSS  lecture 5Web Design Course: CSS  lecture 5
Web Design Course: CSS lecture 5
Gheyath M. Othman
 
Introduction to HTML and CSS
Introduction to HTML and CSSIntroduction to HTML and CSS
Introduction to HTML and CSS
Ferdous Mahmud Shaon
 
GDI Seattle Intermediate HTML and CSS Class 1
GDI Seattle Intermediate HTML and CSS Class 1GDI Seattle Intermediate HTML and CSS Class 1
GDI Seattle Intermediate HTML and CSS Class 1
Heather Rock
 
Cascading Style Sheets
Cascading Style SheetsCascading Style Sheets
Cascading Style Sheets
Senthil Kumar
 
Cascading style sheet
Cascading style sheetCascading style sheet
Cascading style sheet
VARSHAKUMARI49
 
Html
HtmlHtml
Html
VARSHAKUMARI49
 
LIS3353 SP12 Week 4
LIS3353 SP12 Week 4LIS3353 SP12 Week 4
LIS3353 SP12 Week 4
Amanda Case
 
Modular HTML, CSS, & JS Workshop
Modular HTML, CSS, & JS WorkshopModular HTML, CSS, & JS Workshop
Modular HTML, CSS, & JS Workshop
Shay Howe
 
About Best friends - HTML, CSS and JS
About Best friends - HTML, CSS and JSAbout Best friends - HTML, CSS and JS
About Best friends - HTML, CSS and JS
Naga Harish M
 
Web front end development introduction to html css and javascript
Web front end development introduction to html css and javascriptWeb front end development introduction to html css and javascript
Web front end development introduction to html css and javascript
Marc Huang
 
Introduction to HTML and CSS
Introduction to HTML and CSSIntroduction to HTML and CSS
Introduction to HTML and CSS
Mario Hernandez
 
Web design-workflow
Web design-workflowWeb design-workflow
Web design-workflow
Peter Kaizer
 
Comparing xaml and html
Comparing xaml and htmlComparing xaml and html
Comparing xaml and html
Kevin DeRudder
 
The Future Of CSS
The Future Of CSSThe Future Of CSS
The Future Of CSS
Andy Budd
 
ARTDM 171, Week 5: CSS
ARTDM 171, Week 5: CSSARTDM 171, Week 5: CSS
ARTDM 171, Week 5: CSS
Gilbert Guerrero
 
Css week11 2019 2020 for g10 by eng.osama ghandour
Css week11 2019 2020 for g10 by eng.osama ghandourCss week11 2019 2020 for g10 by eng.osama ghandour
Css week11 2019 2020 for g10 by eng.osama ghandour
Osama Ghandour Geris
 
Spectrum 2015 going online with style - an intro to css
Spectrum 2015   going online with style - an intro to cssSpectrum 2015   going online with style - an intro to css
Spectrum 2015 going online with style - an intro to css
Neil Perlin
 
Web Design Course: CSS lecture 2
Web Design Course: CSS  lecture 2Web Design Course: CSS  lecture 2
Web Design Course: CSS lecture 2
Gheyath M. Othman
 
CSS - OOCSS, SMACSS and more
CSS - OOCSS, SMACSS and moreCSS - OOCSS, SMACSS and more
CSS - OOCSS, SMACSS and more
Russ Weakley
 
Web Design Course: CSS lecture 5
Web Design Course: CSS  lecture 5Web Design Course: CSS  lecture 5
Web Design Course: CSS lecture 5
Gheyath M. Othman
 
GDI Seattle Intermediate HTML and CSS Class 1
GDI Seattle Intermediate HTML and CSS Class 1GDI Seattle Intermediate HTML and CSS Class 1
GDI Seattle Intermediate HTML and CSS Class 1
Heather Rock
 
Cascading Style Sheets
Cascading Style SheetsCascading Style Sheets
Cascading Style Sheets
Senthil Kumar
 
LIS3353 SP12 Week 4
LIS3353 SP12 Week 4LIS3353 SP12 Week 4
LIS3353 SP12 Week 4
Amanda Case
 
Modular HTML, CSS, & JS Workshop
Modular HTML, CSS, & JS WorkshopModular HTML, CSS, & JS Workshop
Modular HTML, CSS, & JS Workshop
Shay Howe
 
About Best friends - HTML, CSS and JS
About Best friends - HTML, CSS and JSAbout Best friends - HTML, CSS and JS
About Best friends - HTML, CSS and JS
Naga Harish M
 
Web front end development introduction to html css and javascript
Web front end development introduction to html css and javascriptWeb front end development introduction to html css and javascript
Web front end development introduction to html css and javascript
Marc Huang
 
Introduction to HTML and CSS
Introduction to HTML and CSSIntroduction to HTML and CSS
Introduction to HTML and CSS
Mario Hernandez
 
Web design-workflow
Web design-workflowWeb design-workflow
Web design-workflow
Peter Kaizer
 
Comparing xaml and html
Comparing xaml and htmlComparing xaml and html
Comparing xaml and html
Kevin DeRudder
 
The Future Of CSS
The Future Of CSSThe Future Of CSS
The Future Of CSS
Andy Budd
 
Css week11 2019 2020 for g10 by eng.osama ghandour
Css week11 2019 2020 for g10 by eng.osama ghandourCss week11 2019 2020 for g10 by eng.osama ghandour
Css week11 2019 2020 for g10 by eng.osama ghandour
Osama Ghandour Geris
 
Spectrum 2015 going online with style - an intro to css
Spectrum 2015   going online with style - an intro to cssSpectrum 2015   going online with style - an intro to css
Spectrum 2015 going online with style - an intro to css
Neil Perlin
 

Similar to Html Css (20)

Html and css easy steps
Html and css easy stepsHtml and css easy steps
Html and css easy steps
Biswa Ranjan
 
Html Css
Html CssHtml Css
Html Css
pumas26
 
ch04-css-basics_final.ppt
ch04-css-basics_final.pptch04-css-basics_final.ppt
ch04-css-basics_final.ppt
GmachImen
 
Css
CssCss
Css
myrajendra
 
Chapter_1_Web_Technologies_Basics (CSS)_Part_2.pptx
Chapter_1_Web_Technologies_Basics (CSS)_Part_2.pptxChapter_1_Web_Technologies_Basics (CSS)_Part_2.pptx
Chapter_1_Web_Technologies_Basics (CSS)_Part_2.pptx
eyasu6
 
Learning CSS for beginners.ppt all that are but
Learning CSS for beginners.ppt all that are butLearning CSS for beginners.ppt all that are but
Learning CSS for beginners.ppt all that are but
DangyiGodSees
 
CSS
CSSCSS
CSS
Raja Kumar Ranjan
 
Cascading style sheets
Cascading style sheetsCascading style sheets
Cascading style sheets
smithaps4
 
Web Engineering - Introduction to CSS
Web Engineering - Introduction to CSSWeb Engineering - Introduction to CSS
Web Engineering - Introduction to CSS
Nosheen Qamar
 
Cascading style sheets
Cascading style sheetsCascading style sheets
Cascading style sheets
smitha273566
 
cascadingstylesheets,introduction.css styles-210909054722.pptx
cascadingstylesheets,introduction.css styles-210909054722.pptxcascadingstylesheets,introduction.css styles-210909054722.pptx
cascadingstylesheets,introduction.css styles-210909054722.pptx
hannahroseline2
 
Css Basics
Css BasicsCss Basics
Css Basics
Jay Patel
 
Css training tutorial css3 &amp; css4 essentials
Css training tutorial css3 &amp; css4 essentialsCss training tutorial css3 &amp; css4 essentials
Css training tutorial css3 &amp; css4 essentials
QA TrainingHub
 
Css
CssCss
Css
actacademy
 
Css
CssCss
Css
actacademy
 
LIS3353 SP12 Week 13
LIS3353 SP12 Week 13LIS3353 SP12 Week 13
LIS3353 SP12 Week 13
Amanda Case
 
CSS
CSSCSS
CSS
Jussi Pohjolainen
 
Web Design Bootcamp - Day1
Web Design Bootcamp - Day1Web Design Bootcamp - Day1
Web Design Bootcamp - Day1
Aslam Najeebdeen
 
Unitegergergegegegetgegegegegegeg-2-CSS.pptx
Unitegergergegegegetgegegegegegeg-2-CSS.pptxUnitegergergegegegetgegegegegegeg-2-CSS.pptx
Unitegergergegegegetgegegegegegeg-2-CSS.pptx
VikasTuwar1
 
Ifi7174 lesson2
Ifi7174 lesson2Ifi7174 lesson2
Ifi7174 lesson2
Sónia
 
Html and css easy steps
Html and css easy stepsHtml and css easy steps
Html and css easy steps
Biswa Ranjan
 
Html Css
Html CssHtml Css
Html Css
pumas26
 
ch04-css-basics_final.ppt
ch04-css-basics_final.pptch04-css-basics_final.ppt
ch04-css-basics_final.ppt
GmachImen
 
Chapter_1_Web_Technologies_Basics (CSS)_Part_2.pptx
Chapter_1_Web_Technologies_Basics (CSS)_Part_2.pptxChapter_1_Web_Technologies_Basics (CSS)_Part_2.pptx
Chapter_1_Web_Technologies_Basics (CSS)_Part_2.pptx
eyasu6
 
Learning CSS for beginners.ppt all that are but
Learning CSS for beginners.ppt all that are butLearning CSS for beginners.ppt all that are but
Learning CSS for beginners.ppt all that are but
DangyiGodSees
 
Cascading style sheets
Cascading style sheetsCascading style sheets
Cascading style sheets
smithaps4
 
Web Engineering - Introduction to CSS
Web Engineering - Introduction to CSSWeb Engineering - Introduction to CSS
Web Engineering - Introduction to CSS
Nosheen Qamar
 
Cascading style sheets
Cascading style sheetsCascading style sheets
Cascading style sheets
smitha273566
 
cascadingstylesheets,introduction.css styles-210909054722.pptx
cascadingstylesheets,introduction.css styles-210909054722.pptxcascadingstylesheets,introduction.css styles-210909054722.pptx
cascadingstylesheets,introduction.css styles-210909054722.pptx
hannahroseline2
 
Css training tutorial css3 &amp; css4 essentials
Css training tutorial css3 &amp; css4 essentialsCss training tutorial css3 &amp; css4 essentials
Css training tutorial css3 &amp; css4 essentials
QA TrainingHub
 
LIS3353 SP12 Week 13
LIS3353 SP12 Week 13LIS3353 SP12 Week 13
LIS3353 SP12 Week 13
Amanda Case
 
Web Design Bootcamp - Day1
Web Design Bootcamp - Day1Web Design Bootcamp - Day1
Web Design Bootcamp - Day1
Aslam Najeebdeen
 
Unitegergergegegegetgegegegegegeg-2-CSS.pptx
Unitegergergegegegetgegegegegegeg-2-CSS.pptxUnitegergergegegegetgegegegegegeg-2-CSS.pptx
Unitegergergegegegetgegegegegegeg-2-CSS.pptx
VikasTuwar1
 
Ifi7174 lesson2
Ifi7174 lesson2Ifi7174 lesson2
Ifi7174 lesson2
Sónia
 
Ad

More from Adil Jafri (20)

Csajsp Chapter5
Csajsp Chapter5Csajsp Chapter5
Csajsp Chapter5
Adil Jafri
 
Php How To
Php How ToPhp How To
Php How To
Adil Jafri
 
Owl Clock
Owl ClockOwl Clock
Owl Clock
Adil Jafri
 
Programming Asp Net Bible
Programming Asp Net BibleProgramming Asp Net Bible
Programming Asp Net Bible
Adil Jafri
 
Tcpip Intro
Tcpip IntroTcpip Intro
Tcpip Intro
Adil Jafri
 
Network Programming Clients
Network Programming ClientsNetwork Programming Clients
Network Programming Clients
Adil Jafri
 
Jsp Tutorial
Jsp TutorialJsp Tutorial
Jsp Tutorial
Adil Jafri
 
Ta Javaserverside Eran Toch
Ta Javaserverside Eran TochTa Javaserverside Eran Toch
Ta Javaserverside Eran Toch
Adil Jafri
 
Csajsp Chapter10
Csajsp Chapter10Csajsp Chapter10
Csajsp Chapter10
Adil Jafri
 
Javascript
JavascriptJavascript
Javascript
Adil Jafri
 
Flashmx Tutorials
Flashmx TutorialsFlashmx Tutorials
Flashmx Tutorials
Adil Jafri
 
Java For The Web With Servlets%2cjsp%2cand Ejb
Java For The Web With Servlets%2cjsp%2cand EjbJava For The Web With Servlets%2cjsp%2cand Ejb
Java For The Web With Servlets%2cjsp%2cand Ejb
Adil Jafri
 
Csajsp Chapter12
Csajsp Chapter12Csajsp Chapter12
Csajsp Chapter12
Adil Jafri
 
Html Frames
Html FramesHtml Frames
Html Frames
Adil Jafri
 
Flash Tutorial
Flash TutorialFlash Tutorial
Flash Tutorial
Adil Jafri
 
C Programming
C ProgrammingC Programming
C Programming
Adil Jafri
 
Csajsp Chapter5
Csajsp Chapter5Csajsp Chapter5
Csajsp Chapter5
Adil Jafri
 
Programming Asp Net Bible
Programming Asp Net BibleProgramming Asp Net Bible
Programming Asp Net Bible
Adil Jafri
 
Network Programming Clients
Network Programming ClientsNetwork Programming Clients
Network Programming Clients
Adil Jafri
 
Ta Javaserverside Eran Toch
Ta Javaserverside Eran TochTa Javaserverside Eran Toch
Ta Javaserverside Eran Toch
Adil Jafri
 
Csajsp Chapter10
Csajsp Chapter10Csajsp Chapter10
Csajsp Chapter10
Adil Jafri
 
Flashmx Tutorials
Flashmx TutorialsFlashmx Tutorials
Flashmx Tutorials
Adil Jafri
 
Java For The Web With Servlets%2cjsp%2cand Ejb
Java For The Web With Servlets%2cjsp%2cand EjbJava For The Web With Servlets%2cjsp%2cand Ejb
Java For The Web With Servlets%2cjsp%2cand Ejb
Adil Jafri
 
Csajsp Chapter12
Csajsp Chapter12Csajsp Chapter12
Csajsp Chapter12
Adil Jafri
 
Flash Tutorial
Flash TutorialFlash Tutorial
Flash Tutorial
Adil Jafri
 
Ad

Recently uploaded (20)

Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 

Html Css

  • 1. 1 1 © 2001-2003 Marty Hall, Larry Brown http://www.corewebprogramming.com Web core programming Cascading Style Sheets Cascading Style Sheets2 www.corewebprogramming.com Agenda • Specifying style sheet rules • External and inline style specifications • Creating new HTML elements through style sheet classes • Specifying font and text properties • Controlling foreground and background properties • Netscape LAYERs • Creating layers through style sheets
  • 2. 2 Cascading Style Sheets3 www.corewebprogramming.com Benefits of Cascading Style Sheets • Powerful and flexible way to specify the formatting of HTML elements – Can define font, size, background color, background image, margins, etc. • Share style sheets across multiple documents or entire Web site • Can specify a class definition for a style, effectively defining new HTML elements • Rules are applied in a hierarchical manner (precedence rules) Cascading Style Sheets4 www.corewebprogramming.com Cascading Style Sheets • CSS, Level 1 (1996) – Concerned with applying simple styles to HTML elements – http://www.w3.org/TR/REC-CSS1 • CSS, Level 2 (1998) – Supports media-specific style sheets (visual browsers, aural devices, printers, braille devices) – http://www.w3.org/TR/REC-CSS2 • CSS, Level 3 (draft 2001) – Focused on modularization of the CSS specification – http://www.w3.org/TR/css3-roadmap/ • Note: – CSS1 is supported by Netscape and Internet Explorer 4.x and above – See http://www.webreview.com/style/css1/charts/mastergrid.shtml for a summary of browser compatibility
  • 3. 3 Cascading Style Sheets5 www.corewebprogramming.com Specifying Style Rules • General form of rule selector { property: value } or selector { property1: value1; property2: value2; ... propertyN: valueN } • Example H1 { text-align: center; color: blue } Cascading Style Sheets6 www.corewebprogramming.com Fizzics1.html, Example (no style sheet) <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE>New Advances in Physics</TITLE> </HEAD> <BODY> <H1>New Advances in Physics</H1> <H2>Turning Gold into Lead</H2> In a startling breakthrough, scientist B.O. "Gus" Fizzics has invented a <STRONG>practical</STRONG> technique for transmutation! For more details, please see <A HREF="give-us-your-gold.html">our transmutation thesis</A>. ... </BODY> </HTML>
  • 4. 4 Cascading Style Sheets7 www.corewebprogramming.com Fizzics1.html, Result (no style sheet) Cascading Style Sheets8 www.corewebprogramming.com Fizzics2.html, Example (with style sheet) • Style information <HEAD> <TITLE>Document Title</TITLE> <STYLE TYPE="text/css"> <!-- BODY { background: URL(images/confetti-background.jpg) } H1 { text-align: center; font-family: Blackout } H2 { font-family: MeppDisplayShadow } STRONG { text-decoration: underline } --> </STYLE> </HEAD>
  • 5. 5 Cascading Style Sheets9 www.corewebprogramming.com Fizzics2.html, Result (with style sheet) Cascading Style Sheets10 www.corewebprogramming.com External Style Sheets • Specify link to external style sheet in the HEAD section of the HTML document <LINK REL=STYLESHEET HREF="Sitestyle.css" // Absolute or relative link TYPE="text/css"> • Sitestyle.css /* Example of an external style sheet */ H1 { text-align: center; font-family: Arial } H2 { color: #440000; text-align: center; font-family: Arial Black, Arial, Helvetica, sans-serif } ...
  • 6. 6 Cascading Style Sheets11 www.corewebprogramming.com Inline Style Specification • Use the STYLE attribute defined for each HTML element to directly specify the style • Example ... <H1>New Advances in Physics</H1> <P STYLE="margin-left: 0.5in; margin-right: 0.5in; font-style: italic"> This paper gives the solution to three previously unsolved problems: turning lead into gold, antigravity, and a practical perpetual motion machine. ... Cascading Style Sheets12 www.corewebprogramming.com Defining Style Classes • To define an element style class proceed the HTML element by a period and class name // Define an "abstract" paragraph type P.abstract { margin-left: 0.5in; margin-right: 0.5in; font-style: italic } • To use, supply the name of the style class in the CLASS attribute of the HTML element <H1>New Advances in Physics</H1> <P CLASS="abstract"> This paper gives the solution to three previously unsolved problems: turning lead into gold, antigravity, and a practical perpetual motion machine.
  • 7. 7 Cascading Style Sheets13 www.corewebprogramming.com Defining Style Classes • To define a global style class, omit the element name // Style available to all elements .blue { color: blue; font-weight: bold } • To use, simple specify the style class in the CLASS attribute of the HTML element <H2 CLASS="blue">A Blue Heading</H2> <!-- Apply to a section of text --> This text is in the default color, but <SPAN CLASS="blue">this text is blue.</SPAN> Cascading Style Sheets14 www.corewebprogramming.com Defining Styles through User-Defined IDs • An ID is like a class but can be applied only once in a document <HEAD> <TITLE>...</TITLE> <STYLE TYPE="text/css"> <!-- #foo { color: red } --> </STYLE> </HEAD> <BODY> ... <P ID="foo"> ... </BODY>
  • 8. 8 Cascading Style Sheets15 www.corewebprogramming.com Style Sheet Precedence Rules 1. Rules marked “important” have the highest priority (rarely used) H1 { color: black !important; font-family: sans-serif } 2. Author rules have precedence over reader rules • Style sheet rules override browser preferences Cascading Style Sheets16 www.corewebprogramming.com Style Sheet Precedence Rules, cont. 3. More specific rules have precedence over less specific rules #foo { ... } // ID selector highest priority P.big H1 { ... } // Class higher over element P STRONG { ... } // Two tags higher than single tag STRONG { ... } 4. In case of tie, the last rule has priority
  • 9. 9 Cascading Style Sheets17 www.corewebprogramming.com Useful Font Properties • font-weight – Relative weight (boldness) of font – normal | lighter | bold | bolder | 100 | 200 | ... | 900 H1 { font-weight : 200 } H2 { font-weight : bolder } • font-style – Font face type within a family – normal | italic | oblique P { font-style : normal } TH { font-sytle : italic } Cascading Style Sheets18 www.corewebprogramming.com Useful Font Properties, cont. • font-size – Either relative or absolute size of font – pt, pc, in, cm, mm | em, ex, px, % | xx-large | x-large | large | medium | small | x-small | xx-small | smaller | larger STRONG { font-size: 150% } P { font-size: 14pt } P { font-size: xx-large } • font-family – Typeface family for the font H1 { font-family: Arial }
  • 10. 10 Cascading Style Sheets19 www.corewebprogramming.com CampBearClaw.html, Example <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE>Camp Bear Claw</TITLE> <LINK REL=STYLESHEET HREF="CampBearClaw.css" TYPE="text/css"> </HEAD> <BODY> <H1>Camp Bear Claw</H1> We have the following activities: <H2 CLASS="archery">Archery</H2> <H2 CLASS="arts">Arts and Crafts</H2> <H2 CLASS="horseback">Horseback Riding</H2> <H2 CLASS="hiking">Hiking</H2> <H2 CLASS="campfire">Campfire Song Times</H2> <H2 CLASS="java">Java Programming</H2> </BODY> </HTML> Cascading Style Sheets20 www.corewebprogramming.com CampBearClaw.css H1 { text-align: center; font-family: Funstuff } H2.archery { font-family: ArcheryDisplay } H2.arts { font-family: ClampettsDisplay } H2.horseback { font-family: Rodeo } H2.hiking { font-family: SnowtopCaps } H2.campfire { font-family: Music Hall } H2.java { font-family: Digiface }
  • 11. 11 Cascading Style Sheets21 www.corewebprogramming.com CampBearClaw.html, Result Cascading Style Sheets22 www.corewebprogramming.com Useful Text Properties • text-decoration – Describes text additions or “decorations” that are added to the text of an element – none | underline | overline | line-through | blink P { text-decoration: underline } • vertical-align – Determines how elements are positioned vertically – top | bottom | baseline | middle | sub | super | text-top | text-bottom | % • text-align – Determines how paragraphs are positioned horizontally – left | right | center | justify
  • 12. 12 Cascading Style Sheets23 www.corewebprogramming.com Useful Text Properties, cont. • text-indent – Specifies the indentation of the first line of the paragraph – +/– pt, pc, in, cm, mm | +/– em, ex, px, % P { text-indent: -25px } /* Hanging indent */ • line-height – Specifies the distance between two consecutive baselines in a paragraph – normal | number | pt, pc, in, cm, mm | em, ex, px, % .double { line-height: 200% } .triple { line-height: 3 } /* 3x the font size */ DIV { line-height: 1.5em } Cascading Style Sheets24 www.corewebprogramming.com Bates.html <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE>An Open Letter to the IRS</TITLE> <LINK REL=STYLESHEET HREF="Bates.css" TYPE="text/css"> </HEAD> <BODY BACKGROUND="images/bond-paper.jpg"> <P CLASS="rhead"> April 1, 2001 <HR> <P CLASS="rhead"> William A. Bates<BR> Macrosoft Corporation<BR> Blumond, WA 12345 <P CLASS="lhead"> Internal Revenue Service<BR> Philadelphia, PA 67890 <P> <BR> Dear Sirs, <P CLASS="body"> I am writing to inform you that, due to financial difficulties, ...
  • 13. 13 Cascading Style Sheets25 www.corewebprogramming.com Bates.css P { margin-top: 5px } P.rhead { text-align: right; margin-right: 0.5in; font-family: sans-serif } P.lhead { font-family: sans-serif } P.body { text-align: justify; text-indent: 0.5in } P.foot { margin-left: 60%; line-height: 300% } Cascading Style Sheets26 www.corewebprogramming.com Bates.html
  • 14. 14 Cascading Style Sheets27 www.corewebprogramming.com Useful Foreground and Background Properties • color – Color of the text or foreground color – color-name | #RRGGBB | #RGB | rgb(rrr, ggg, bbb) | rgb(rrr%, ggg%, bbb%) P { color : blue } H1 { color : #00AABB } H3 { color : rgb(255, 0, 0 ) } /* red */ • background-image – none | url(filename) – Specifies an image to use as the background of region H2 { background-image: url(Bluedrop.gif);} Cascading Style Sheets28 www.corewebprogramming.com Useful Foreground and Background Properties, cont. • background-repeat – Specifies how to tile the image in the region – repeat | repeat-x | repeat-y | norepeat BODY { background-image: url(Bluedot.gif); background-repeat: repeat-x; } • background – Lets you combine properties in a single entry P { background: url(wallpaper.jpg) repeat-x }
  • 15. 15 Cascading Style Sheets29 www.corewebprogramming.com Cabinets.html, Example <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE>Joe's Cabinets</TITLE> <LINK REL=STYLESHEET HREF="Cabinets.css" TYPE="text/css"> </HEAD> <BODY> <CENTER> <TABLE WIDTH=360 HEIGHT=199> <TR><TD ALIGN="CENTER" CLASS="banner">Joe's Cabinets </TABLE> </CENTER> <P> Welcome to Joe's Cabinets. We specialize in <UL> <LI>Custom Cabinets <LI>Kitchen Remodeling <!-- Etc --> </UL> <!-- Etc --> </BODY> </HTML> Cascading Style Sheets30 www.corewebprogramming.com Cabinets.css .banner { background: url(images/boards.jpg) repeat-x; font-size: 50pt; font-family: Arial Rounded MT Bold }
  • 16. 16 Cascading Style Sheets31 www.corewebprogramming.com Cabinets.html, Result Cascading Style Sheets32 www.corewebprogramming.com Properties of the Bounding Box • CSS assume that all elements result in one or more rectangular regions (bounding box) • Styles can specify the margins, borders, and padding of the bounding box P { margin: 0.25in; border: 0.25in solid black; padding: 0.25in; background: URL(images/bond-paper.jpg) }
  • 17. 17 Cascading Style Sheets33 www.corewebprogramming.com The Bounding Box Cascading Style Sheets34 www.corewebprogramming.com Images and Floating Elements • width, height – Specify a fixed size for an element (usually an image) – auto | pt, pc, in, cm, mm | em, ex, px IMG.bullet { width: 50px; height: 50px } • float – This property lets elements float into the left or right margins where the text wrapping arounds – none | left | right
  • 18. 18 Cascading Style Sheets35 www.corewebprogramming.com Psalm23.html <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE>The 23rd Psalm</TITLE> <STYLE> <!-- SPAN { float: left; font-family: "Cushing Book"; font-size: 75pt } --> </STYLE> </HEAD> <BODY> <H2 ALIGN="CENTER"> The 23rd Psalm (King James Version)</H2> <SPAN>T</SPAN>he LORD is my shepherd; I shall not want. He maketh me to lie down in green pastures: he leadeth me beside the still waters. He restoreth my soul: he leadeth me in the paths of righteousness for his name's sake. Yea, Cascading Style Sheets36 www.corewebprogramming.com Psalm23.html, Result The float property can be used to implement “drop caps”
  • 19. 19 Cascading Style Sheets37 www.corewebprogramming.com Effect of Paragraph Breaks, Example, cont. Adding a <P> element simply continues the flow Adding <P STYLE="clear: left"> forces the next paragraph to start after the floating element Cascading Style Sheets38 www.corewebprogramming.com Netscape Layers • Layers (LAYER and ILAYER elements) allow you to: – Place HTML markup in separate regions – Position each region on the page • LAYER and ILAYER are only supported in Netscape 4 – Layers are not supported in Internet Explorer or Netscape 6
  • 20. 20 Cascading Style Sheets39 www.corewebprogramming.com LAYER and ILAYER • LAYER element – The LAYER element creates regions that have an absolute position with respect to the window or parent layer • ILAYER – The ILAYER element creates inline layers (regions that are embedded in the flow of the text) Cascading Style Sheets40 www.corewebprogramming.com LAYER, Example <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE>Using ABOVE and BELOW</TITLE> </HEAD> <BODY> <H1>Using <CODE>ABOVE</CODE> and <CODE>BELOW</CODE></H1> <LAYER ID="Top" LEFT=60 TOP=120 WIDTH=500 HEIGHT=100 BGCOLOR="#F5DEB3"> This layer is on top, even though it appears first in the HTML document. </LAYER> <LAYER ID="Bottom" ABOVE="Top" LEFT=10 TOP=70 WIDTH=500 HEIGHT=100 BGCOLOR="gray"> This layer is on the bottom, even though it appears second in the HTML document. </LAYER> </BODY> </HTML>
  • 21. 21 Cascading Style Sheets41 www.corewebprogramming.com LAYER, Result Netscape 4 layers can specify the relative order of the layers. Cascading Style Sheets42 www.corewebprogramming.com ILAYER, Example <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE>Row, Row, Row Your Boat</TITLE> </HEAD> <BODY> <IMG SRC="images/Rowboat.gif" ALIGN="RIGHT"> <HR> <B>Row, Row, Row Your Boat</B><BR> Row, row, row your boat<BR> Gently <ILAYER TOP=10>down</ILAYER> <ILAYER TOP=20>the</ILAYER> <ILAYER TOP=30>stream<BR> Merrily, merrily, merrily, merrily<BR> Life is but a dream<BR> <HR> </ILAYER> </BODY> </HTML>
  • 22. 22 Cascading Style Sheets43 www.corewebprogramming.com ILAYER, Result Using TOP in ILAYER can move text up or down in the current paragraph. Cascading Style Sheets44 www.corewebprogramming.com Specifying Layers with Style Sheets • Style sheets provide an alternative to LAYER and ILAYER elements – Style sheet layers are supported by both Netscape and Internet Explorer – However, Netscape layers are more complete • No equivalent style for PAGEX and PAGEY for positioning • Problem – Netscape and IE use a different object model to refer to layers – See http://www.stopbadtherapy.com/standards.shtml for creating cross-browser layers
  • 23. 23 Cascading Style Sheets45 www.corewebprogramming.com Creating a Style Sheet Layer • Use an ID tag format to define a style #layer1 { position: absolute; left: 50px; top: 75px; ... } • Define the layer through a DIV or SPAN element <SPAN ID="layer1"> ... </SPAN> <DIV ID="layer2"> ... </DIV> Cascading Style Sheets46 www.corewebprogramming.com Useful Layer Properties • left, top – Specifies the left and top sides of the layer relative to the parent window • position – Describes how the position is defined to the parent window – absolute, relative, static • visibility – Determines whether a layer is visible or hidden – visible, hidden, inherit
  • 24. 24 Cascading Style Sheets47 www.corewebprogramming.com Dynamically Changing a Layer’s Visibility, Example <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE>Changing Visibility Dynamically</TITLE> <STYLE> <!-- #layer1 { position: absolute; left: 0.25in; top: 1.5in; color: black; background-color: #F5DEB3; visibility: hidden } #layer2 { position: absolute; left: 0.25in; top: 1.5in; color: #F5DEB3; background-color: black; visibility: hidden } H1 { text-align: center; font-family: Arial } FORM { text-align: center } --> </STYLE> ... Cascading Style Sheets48 www.corewebprogramming.com Dynamically Changing a Layer’s Visibility, Example <SCRIPT TYPE="text/javascript"> <!-- function display(value1, value2){ if(document.layers) { // Test for Netscape. document.layers.layer1.visibility = value1; document.layers.layer2.visibility = value2; } else { document.all.layer1.style.visibility = value1; document.all.layer2.style.visibility = value2; } } //--> </SCRIPT> </HEAD> <BODY BGCOLOR="WHITE"> <H1>Changing Visibility Dynamically</H1> <FORM> <INPUT TYPE="BUTTON" VALUE="Show Layer1" onClick="display('visible', 'hidden')"> <INPUT TYPE="BUTTON" VALUE="Show Layer2" onClick="display('hidden', 'visible')"> </FORM> ...
  • 25. 25 Cascading Style Sheets49 www.corewebprogramming.com Dynamically Changing a Layer’s Visibility, Example ... <DIV ID="layer1"> <H1>This is layer1.</H1> </DIV> <DIV ID="layer2"> <H1>This is layer2.</H1> </DIV> </BODY> </HTML> Cascading Style Sheets50 www.corewebprogramming.com Dynamically Changing a Layer’s Visibility, Result Selecting a button displays a hidden layer.
  • 26. 26 Cascading Style Sheets51 www.corewebprogramming.com Appendix, Length Units Unit Description cm Centimeters (absolute unit) em The height of the current font (relative unit) ex The height of the letter “x” in the current font (relative unit) in Inches (absolute unit) mm Millimeters (absolute unit) pc Picas; 6 picas per inch; 12 points per pica (absolute unit) pt Points; 72 points per inch (absolute unit) px Pixels (relative unit) Cascading Style Sheets52 www.corewebprogramming.com Summary • Through style sheets you can specify the general formatting of HTML elements • Use external style sheets to share styles across all documents in the Web site • Class definitions allow you to define multiple styles for an HTML element • LAYERs are only supported by Netscape 5; however, a viable alternative are style sheet layers
  • 27. 27 53 © 2001-2003 Marty Hall, Larry Brown http://www.corewebprogramming.com Web core programming Questions?