css refresher

18

Click here to load reader

Upload: gerson-abesamis

Post on 06-May-2015

3.193 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CSS Refresher

CSS REFRESHERStyling HTML elements

Page 2: CSS Refresher

what is css?• Cascading Style Sheets

• A set of rules on how to display your HTML elements

• Internal documents: embedded in the head part of the HTML file

• External documents: something.css

Page 3: CSS Refresher

Basic CSS RULE

Page 4: CSS Refresher

SELECTORS• Tag/element: p {color:black;}

<p>This text will be black</p>

• ID: #alternate {color:green;}<p id=“alternate”>This will be green</p>

• Class: .another {color:blue;}<p class=“another”>While this will be blue</p>

Page 5: CSS Refresher

MORE SELECTORS• Element-specific: p.red {color:red;}

<p class=“red”>This text will be red</p>

• Multiple elements: .title, .head {color:pink;}<h1 class=“head”>Pink Heading</h1><p class=“title”>Pink Title</p>

Page 6: CSS Refresher

HOW to apply CSS

• Internal stylesheet

• External stylesheet

• Inline stylesheet

Page 7: CSS Refresher

INTERNAL CSS<head><style type=“text/css”>p.red {color:red;}</style></head>

Page 8: CSS Refresher

EXTERNAL CSS

<head><link rel=“stylesheet” type=“text/css” href= “samples.css” /></head>

Page 9: CSS Refresher

INLINE CSS

<a href=“somewhere.html” style= “color:black;text-size:25px”>This is a link</a>

Page 10: CSS Refresher

CASCADING• Elements can inherit rules from

multiple style sheets

• Inheritance order:

1. Browser default

2. External stylesheet

3. Internal stylesheet

4. Inline style

Page 11: CSS Refresher

Exception!<head><style type=“text/css”>p.red {color:red;}</style><link rel=“stylesheet” type=“text/css” href= “samples.css” /></head>

Page 12: CSS Refresher

RULES: BACKGROUNDbody {background-color:#000000;background-image:url(‘bg.gif’);background-repeat:repeat-y;background-attachment:scroll;background-position:right top;}

Page 13: CSS Refresher

RULES: BACKGROUND

body {background:#000000 url(‘bg.gif’)repeat-y scroll right top}

Page 14: CSS Refresher

RULES: TEXTh1 {color:blue;text-align:right;text-decoration:underline;text-transform:uppercase;text-indent:50px;}

Page 15: CSS Refresher

RULES: TEXT

h1 {word-spacing:10px;line-height:30px;letter-spacing:-5px;}

Page 16: CSS Refresher

RULES: FONTp.font {font-family:“Times New Roman”, Verdana, Arial;font-style:italic;font-size:16px;font-variant:small-caps;font-weight:bolder;}

Page 17: CSS Refresher

Web units

• pixel: font-size:32px

• percent: font-size:200%

• em: font-size:2em

Page 18: CSS Refresher

LINK STYLES

• a:link{color:blue;}

• a:visited{color:green;}

• a:hover{color:pink;}

• a:active{color:black;}