Presentation is loading. Please wait.

Presentation is loading. Please wait.

Cascading Style Sheets CS3505. What are CSS? Method for adding style attributes consistently to HML tags Cascading because styles are applied in order.

Similar presentations


Presentation on theme: "Cascading Style Sheets CS3505. What are CSS? Method for adding style attributes consistently to HML tags Cascading because styles are applied in order."— Presentation transcript:

1 Cascading Style Sheets CS3505

2 What are CSS? Method for adding style attributes consistently to HML tags Cascading because styles are applied in order of priority- local, author style sheet, user style sheet, user browser New tag Ref: Deitel chapter 6, Greenlaw 9.8 http://www.htmlhelp.com/reference/css/quick- tutorial.html

3 CSS Types Inline Imbedded External User global definition for tags in this document applies here … global definition for tags in this document

4 Inline Styles Html tag’s can have style attributes Format style applies here Example: This text has the font- size and color styles applied to it, making it 20pt. and blue. Inline Page Example

5 Embedded Style Sheets Requires style rules in to add styles to html tags appearing in Format: tag {property: value;…property: value} … tag tag {property: value;…property: value}.classname {property: value;…property: value} #IdName {property: value;…property: value}

6 Definition in application in tag {property: value;…property: value} … tag1 tag2 {property: value;…property: value}.classname {property: value;…property: value} tag style applies here nested applies here doesn’t class definition applies here

7 Embedded Style Sheets Example Example a.nodec { text-decoration: none } a:hover { text-decoration: underline; color: red; background-color: #ccffcc }.special { color: green} li em { color: red; font-weight: bold } ul { margin-left: 75px } ul ul { text-decoration: underline; margin-left: 15px } Shopping list for Monday : Milk Bread White bread Rye bread Whole wheat bread Rice Potatoes Pizza with mushrooms Go to the Grocery store

8 Style Rules Comments a.nodec defines a class applied to tags only a:hover syntax for styles applied to hover pseudo-class.special defines a class li em applies rule to nested tag occurrences (see Monday vs with mushrooms) Li,emcomma applies rule to both tags

9 Pseudo Classes and Elements Anchor Pseudo-classes –a:link{color:#ff0000} –a:visited{color:#00ff00} –a:hover{color:#0000ff} –a:active{color:#00ffff} Pseudo Elements –p:first-letter {font-size: 24pt} –p:first-line {color: #00ffff}

10 and *often used in Front page to organize HTML Span is an inline element like or Format … applies here Div is a block element and applies to a region of html which may contain and tags Format … …applies to HTML blocks and paragraphs here

11 and ID divisions Identify a specific DIV or SPAN segment by using the ID mechanism (see more_embedded.html) Define #IDname { Attributes} Use … applies here Example #svp94O { color: red; font-weight: bold}… Text using ID to identify this Red bold H4 line

12 External style sheets Define rules in one file and link them into one or many files Maintains a consistent style over complex webs that are easy to maintain and reuse. Example of external reference: Style definition file Html fileStyle definition file Html file

13 User Style Sheet Define styles you want the browser to use locally Tell your browser to use a local style sheet click tools->internet options->accessibility enter user style sheet path name Allows a local user to define colors, fonts, and sizes more easily readable

14 Style Properties How to find a list of properties which can be modified and the values associated with them Defining document –Cascading Style Sheets, level 1 W3C Recommendation 17 Dec 1996 –http://www.w3.org/TR/REC-CSS1http://www.w3.org/TR/REC-CSS1 –Table of contents has a good list –A Good site for properties definitions http://www.htmlhelp.com/reference/css/properties.html

15 Sample Properties List 4 Formatting model 4.1 Block-level elements 4.1.1 Vertical formatting 4.1.2 Horizontal formatting 4.1.3 List-item elements 4.1.4 Floating elements 4.2 Inline elements 4.3 Replaced elements 4.4 The height of lines 4.5 The canvas 4.6 'BR' elements 5 CSS1 properties 5.1 Notation for property values 5.2 Font properties 5.2.1 Font matching 5.2.2 'font-family' 5.2.3 'font-style' 5.2.4 'font-variant' 5.2.5 'font-weight' 5.2.6 'font-size' 5.2.7 'font' 5.3 Color and background properties 5.3.1 'color' 5.3.2 'background-color' 5.3.3 'background-image' 5.3.4 'background-repeat' 5.3.5 'background-attachment' 5.3.6 'background-position' 5.3.7 'background' 5.4 Text properties 5.4.1 'word-spacing' 5.4.2 'letter-spacing' 5.4.3 'text-decoration' 5.4.4 'vertical-align' 5.4.5 'text-transform' 5.4.6 'text-align' 5.4.7 'text-indent' 5.4.8 'line-height' 5.5 Box properties 5.5.1 'margin-top' 5.5.2 'margin-right' 5.5.3 'margin-bottom' 5.5.4 'margin-left' 5.5.5 'margin' 5.5.6 'padding-top' 5.5.7 'padding-right' 5.5.8 'padding-bottom' 5.5.9 'padding-left' 5.5.10 'padding' 5.5.11 'border-top-width' 5.5.12 'border-right-width' 5.5.13 'border-bottom-width' 5.5.14 'border-left-width' 5.5.15 'border-width' 5.5.16 'border-color' 5.5.17 'border-style' 5.5.18 'border-top' 5.5.19 'border-right' 5.5.20 'border-bottom' 5.5.21 'border-left' 5.5.22 'border' 5.5.23 'width' 5.5.24 'height' 5.5.25 'float' 5.5.26 'clear' 5.6 Classification properties 5.6.1 'display' 5.6.2 'white-space' 5.6.3 'list-style-type' 5.6.4 'list-style-image' 5.6.5 'list-style-position' 5.6.6 'list-style'


Download ppt "Cascading Style Sheets CS3505. What are CSS? Method for adding style attributes consistently to HML tags Cascading because styles are applied in order."

Similar presentations


Ads by Google