Chapter 8 Cascading Style Sheets (CSS). Agenda Definition of a CSS style Types of CSS Styles CSS Backgrounds CSS Text CSS Fonts CSS Links CSS Lists CSS.

Download Chapter 8 Cascading Style Sheets (CSS). Agenda Definition of a CSS style Types of CSS Styles CSS Backgrounds CSS Text CSS Fonts CSS Links CSS Lists CSS.

Post on 24-Dec-2015

229 views

Category:

Documents

2 download

TRANSCRIPT

<ul><li> Slide 1 </li> <li> Chapter 8 Cascading Style Sheets (CSS) </li> <li> Slide 2 </li> <li> Agenda Definition of a CSS style Types of CSS Styles CSS Backgrounds CSS Text CSS Fonts CSS Links CSS Lists CSS Tables CSS Selectors CSS Units CSS Color Values </li> <li> Slide 3 </li> <li> What is CSS? Cascading Style Sheets (CSS) is a style sheet language used for describing the presentation semantics (the look and formatting) of a document written in a markup language. Its most common application is to style web pages written in HTML and XHTML, but the language can also be applied to any kind of XML document. Styles define how to display HTML elements Styles are added to HTML to solve a problem External Style Sheets can save a lot of work External Style Sheets are stored in CSS files </li> <li> Slide 4 </li> <li> Types of CSS Styles 1.Internal Styles are defined in the section of the current web page. 2.Inline Styles are defined within the HTML markup of a particular page element. (avoid using) 3.External Styles are defined on the External Style Sheet, which is linked to the web pages(s). (Best choice) </li> <li> Slide 5 </li> <li> Internal Style Sheet An internal style sheet should be used when a single document has a unique style. You define internal styles in the head section of an HTML page, by using the tag, like this: hr {color:sienna;} p {margin-left:20px;} body {background image:url("images/back40.gif");} </li> <li> Slide 6 </li> <li> Inline Styles An inline style loses many of the advantages of style sheets by mixing content with presentation. Use this method sparingly! To use inline styles you use the style attribute in the relevant tag. The style attribute can contain any CSS property. The example shows how to change the color and the left margin of a paragraph: This is a paragraph. </li> <li> Slide 7 </li> <li> External Styles An external style sheet is ideal when the style is applied to many pages. With an external style sheet, you can change the look of an entire Web site by changing one file. Each page must link to the style sheet using the tag. The tag goes inside the head section: An external style sheet can be written in any text editor. The file should not contain any html tags. Your style sheet should be saved with a.css extension. An example of a style sheet file is shown below: hr {color:sienna;} p {margin-left:20px;} body {background-image:url("images/back40.gif");} </li> <li> Slide 8 </li> <li> Example body {color:red;} h1 {color:#00ff00;} p.ex {color:rgb(0,0,255);} This is heading 1 This is a paragraph. This is an ordinary paragraph. Notice that this text is red. The default text-color for a page is defined in the body selector. This is a paragraph with class="ex". This text is blue. </li> <li> Slide 9 </li> <li> CSS Background Properties PropertyDescription backgroundSets all the background properties in one declaration background-attachment Sets whether a background image is fixed or scrolls with the rest of the page background-colorSets the background color of an element background-imageSets the background image for an element background-positionSets the starting position of a background image background-repeatSets how a background image will be repeated </li> <li> Slide 10 </li> <li> Example of CSS Background body { background-image:url('img_tree.png'); background-repeat:no-repeat; background-position:right top; } h1 {background-color:#6495ed;} p {background-color:#e0ffff;} </li> <li> Slide 17 </li> <li> CSS List Properties PropertyDescription list-style Sets all the properties for a list in one declaration list-style-imageSpecifies an image as the list-item marker list-style-position Specifies if the list-item markers should appear inside or outside the content flow list-style-typeSpecifies the type of list-item marker </li> <li> Slide 18 </li> <li> Example of CSS List Properties ul.a {list-style-type: circle;} ul.b {list-style-type: square;} ol.c {list-style-type: upper-roman;} ol.d {list-style-type: lower-alpha;} ul{list-style-image: url('sqpurple.gif');} ul{list-style-position:inside;} </li> <li> CSS Selectors SelectorExampleExample description.class.introSelects all elements with class="intro" #id#firstnameSelects the element with id="firstname" **Selects all elements elementpSelects all elements element,elementdiv,pSelects all elements and all elements element elementdiv pSelects all elements inside elements element&gt;elementdiv&gt;p Selects all elements where the parent is a element element+elementdiv+p Selects all elements that are placed immediately after elements </li> <li> Slide 24 </li> <li> CSS Units UnitDescription %percentage ininch cmcentimeter mmmillimeter em 1em is equal to the current font size. 2em means 2 times the size of the current font. E.g., if an element is displayed with a font of 12 pt, then '2em' is 24 pt. The 'em' is a very useful unit in CSS, since it can adapt automatically to the font that the reader uses exone ex is the x-height of a font (x-height is usually about half the font-size) ptpoint (1 pt is the same as 1/72 inch) pcpica (1 pc is the same as 12 points) pxpixels (a dot on the computer screen) </li> <li> Slide 25 </li> <li> Color Values ColorColor HEXColor RGB #000000rgb(0,0,0) #FF0000rgb(255,0,0) #00FF00rgb(0,255,0) #0000FFrgb(0,0,255) #FFFF00rgb(255,255,0) #00FFFFrgb(0,255,255) #FF00FFrgb(255,0,255) #C0C0C0rgb(192,192,192) #FFFFFFrgb(255,255,255) </li> <li> Slide 26 </li> <li> Lab 8 Types of CSS Styles CSS Backgrounds CSS Text CSS Fonts CSS Links CSS Lists CSS Tables CSS Selectors CSS Units CSS Color Values </li> </ul>

Recommended

View more >