Title: Basic CSS The Nuts and Bolts
1Basic CSSThe Nuts and Bolts
- Week 3 - Presentation 1
- Veronica Noone
2Objectives
- Lets Review
- CSS Syntax
- Selectors
- Properties and Values
- Applying CSS to XHTML
- Other Style Sheets?
3Lets Review
- What was the Basics of XHTML?
- How is XHTML and CSS Related?
- What is CSS again?
4CSS Syntax
- The jelly to XHTML peanut butter
- Has completely different Syntax
- No tags
- Selectors, properties and values
body background-color green
5CSS Syntax Dissected
Rule
- Selectors
- Properties
- Values
Selector
statement
body background-color green
Property
Value
- The declaration has property/value pairs
separated by semicolons
6Selectors
- Specify what element you want to style
- Three types
- HTML selectors
- ID Selectors
- Class Selectors
7HTML Selectors
- Define how a specific elements should be
displayed - The text portion of an XHTML tag
- For ltpgt - p is the selector
p color green
8ID Selectors
- Rule that can be applied to one specific element
that has the and id attribute - Used when you want to apply a style to one
specific element
myname color red
Notice the sign!
9Class Selectors
- Rule that can be applied to any number of
elements via the class attribute
.alert color red font-weight bold
Notice the .
10classs and ids???
- What are these things we speak of?
- Classes and ids will emerge and make more sense
as we learn more and more about how to structure
our XHTML documents correctly. - For now we are dealing with specifics of the css
language
11Pseudo-classe Selectors
- Increase the specificity of a CSS rule
- Not very many we will cover them in more detail
later.
pfirst-letter font-size150
12Grouped Selectors
- You can apply one statement to multiple selectors
h1, p, .alert font-family verdana
13Nested Selectors
- Remember the parent child relationships elements
have?
p em font-weight bold
14Properties and Values
- We will cover specific Properties as we continue
through the semester - Values normally correspond to specific properties
but there are common ones - Color
- Units
15All about Color
- Colors can be used to specify fonts, backgrounds
and borders. - Over 16 million!
- Specify color values by
- Name (red, green, pink, grey, etc)
- Hexadecimal (ffffff, cc9999, c99)
- RGB value ( rgb(255, 255, 255) )
16Units
- Dealing with size, width, height, thickness, etc
- Percentage (80)
- Em (1.5em)
- Pixel (500px)
- Point (12pt)
- Pica (10pc)
- Centimeter (5cm)
- Millimeter (100mm)
- Inch (2in)
17Now what?
- Youve got the basic rules but where does it GO?
18Applying CSS to XHTML
- Three ways
- Inline
- Embedded
- External
19Inline CSS
- Generally discouraged
- Add style directly to an element
ltp stylecolorredgtThis paragraph will be
redlt/pgt
20Embedded CSS
- Goes in the head of the document using the style
tag. - Only be used when applying styles to one page.
- Will use a lot while learning for simplicity
- Lets take a look
21lt!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Strict//EN" "http//www.w3.org/TR/xhtml1/DTD/xhtml
1-strict.dtd"gt lthtml xmlns"http//www.w3.org/19
99/xhtml" xmllang"en"gt ltheadgt lttitlegtClass
Examplelt/titlegt ltstyle type"text/css"gt body
background-color pink em color purple
font-size 125 font-weight bold lt/stylegt lt/h
eadgt ltbodygt lt!-- main content area
--gt lth1gtTodays Newslt/h1gt ltpgtIt was a
ltemgtgreatlt/emgt class today! Students seemed
mildly interested and they ACTUALLY learned
something!lt/pgt lt/bodygt lt/htmlgt
22External CSS
- The Cats PJs of CSS
- Linked from the HTML file using the, ummm, link
tag. - Can also import using _at_import
ltlink relstylesheet typetext/css
hrefmyCSSfile.css /gt
ltstyle typetext/cssgt _at_import
url(myCSSfile.css) lt/stylegt
23Other Style Sheets?
- What are the 3 ways we can define styles for a
page again? - There are 2 other styles sheets to consider..
- Do you know them? do ya? huh? Huh?
24One thing to remember
- Nothing is absolute on the web except your
CONTENT!