Web Design

(Nancy Kaufman) #1

96


H


TML is a language designed to define the structure of a document. As it evolved, tags were added
to HTML to handle formatting, but these were difficult to work with, difficult to edit, and added

considerably to the page’s file size. Cascading Style Sheets (CSS) was introduced both to solve all of


these issues as well add additional formatting controls. With CSS, you can change your text properties,


control the spacing between elements on your page, draw borders, add images, and much more. You


can use CSS to format any Web page, regardless of the version of HTML or XHTML you are using.


Introduction to CSS


Writing CSS
Like HTML, CSS documents are plain text and can be
written in any text editor. Modern HTML editors include
support for CSS as well, so the editor in which you are
writing your HTML should also work for your CSS.

<meta h
{ //v3.0
x.src=x.o
{ if(!d.M
f (a[i] in

p-equ
var i,x,a
Src; } fu
M_p) d.
dexOf("

v="Content-
=document
ncon MM_
MM_p=new
#")!=0){ d M

Type" c
MM_s
_preloa
Array(
M p[j]

arset=u
h&&(x=a
d=docum
h,a=MM
++] src=

-8"> <sc
[i])&&x.
ment; if(d
_preloa
a[i];}{/

ript typ
oSrc;i++
d.images
dImages
/v4 01 v

CSS Syntax
The syntax of CSS is quite a bit different from HTML. CSS documents are made up of
a series of rules. Each rule includes a selector and a declaration. Selectors are case-
sensitive, whereas the values and properties that make up declarations are not. Like
HTML, CSS is whitespace-insensitive.

orrulesrulesrulesorrules rddddeclarationeclarationeclarationeclaration----
ruleslrules-rules ---declarationdeclarationorordeclarationdeclarationor sitivecase-snotens
se-sensitive


  • ---rationadeclarationdeclarationdeclarationrules rulesrules rules ----

  • ---declarationdeclarationdeclarationdeclarationrulesrules rules rules----lectorlectorlectorector


notcas

rules -


  • rulesrules--- rules

  • --


selectorselectorselectorselector
ionioniondeclaratdeclarationdeclaratdeclarat

selectorselectorselectorselector-- rules--rules rules rules----declarationdeclarationdeclarationdeclarationooo sse sen
case-sensitivenotcas
case-sennotsitive

-sensssselectoselecelecelecootottrrrr----declarationrulesdeclarationdeclarationdeclarationrules rules rules----
se

case-sensitive
case-sensitivenot

selectorselectorselectorselector- rules-- rules - rulesrulesdeclarationdeclaratideclarationdeclaration----onrrororr
case-tivesensitivecase-sennotsitivesi

lallalaalalalaececdedecdecdddedecdecdddecdedddedecdecdecddderrrororororororororoororortororectectectecteectectectectctctecteectelelllelelelellselselselselselsselsselssssel

ceeeceelecelececeellececlsselseelsselseelsesesesselelelselselselsesessessssseltootnonotononotsencase-senitive

vevvveveeveiititisisisisen-case
ionnniononononnionononononononnlataarlarlararratiatiatiatiatiatitctlarlaratiatiatitaticlar

nsitenennnsitsitsitsitensisssitiveiveiveve
ase-sensitivecnot
tiveve sitinveveieeee

esesesses----^ eeseseseseseslulululululululluulululrrrrrrrrrrrrrrrrr rrdeclarationdeclarationeclarationddeclaration-- r----------ctorctorcctorctorleeleeleelesssseselessselessselselesesesese

itiv


  • sensitivecasecc


nottivesensicase-




    • rules rules --
      selectorselector declarationdeclaration
      case-sensitivecase-sensitivenot




Selectors
Selectors define the parts of the HTML document to which the rules
will apply. Selectors can be HTML elements, or they can correspond to
the values of ID or class attributes within HTML. More complex
selectors allow you to apply rules to elements based on their position
relative to other elements.