css fundamentals

22
CSS Fundamentals

Upload: ray-villalobos

Post on 08-May-2015

4.399 views

Category:

Technology


0 download

DESCRIPTION

Fundamentals of CSS covering the different types of tags and

TRANSCRIPT

Page 1: CSS Fundamentals

CSS Fundamentals

Page 2: CSS Fundamentals

What is CSS?

• Cascading Style Sheets

• Rules that define how HTML elements should look

body {background:black;}

• Cascades part determines the order the rules are applied in

Page 3: CSS Fundamentals

Types of Style Sheets

•Browser-Applies some styles by default

•User-Some browsers allow you to create your own styles.

•Author-Websites can also have style sheets...these are the ones you'll be doing.

Page 4: CSS Fundamentals

• selectors select elements to be styled

• declaration tells browser how to style

• property is what you want to modify

• value is the option you want for the property

What does it look like?<style>

em { color:red; font-weight:bold; }</style>

declarationselector property value

Page 5: CSS Fundamentals

Where does CSS go

• Inline style="" attribute - Only good for one tag

• Embedded <style> - Good for the whole page

• External <link rel="stylesheet" href="" /> - Many Pages

Page 6: CSS Fundamentals

• When you need to share code

• Only affects a specific tag

Inline

<em style="color:red;">dog</em>

Page 7: CSS Fundamentals

• Uses the <style> tag

• Affects the current page

• Uses selectors to specify which tags to affect

Embedded

<style> em { color: green; font-size:18px;}</style>

Page 8: CSS Fundamentals

• Can affect a multitude of documents

• Uses a separate file that must be linked to

• The CSS file does NOT need <STYLE> tag

External<link rel="stylesheet" type="text/css" href="my.css" />

Page 9: CSS Fundamentals

HTML Color Modes

• Can use Color Names like Black, Red, Blue

• Can use Red, Green and Blue values from Photoshop

• To be more specific, use Hexadecimal codes #FFCC00

• Can be shortened to three letters if they're the same #FC0

• Newer browsers can use rgba(0,0,0,0.5);

Page 10: CSS Fundamentals

• Children inherit styles from parent

• BODY is the big daddy

Inheritance

body { font-family:verdana; }p { font-size:10px;}

Page 11: CSS Fundamentals

SPECIFICITY

• Which rules take over when there's more than one

• Browsers always deal with multiple style sheets

• Browser/User/Author style sheet/External/embedded/inline

• If two rules conflict, generally the later rule wins

<style>em { color: red; }</style><p>The quick <em style="color:green;">fox</em>.</p>

Page 12: CSS Fundamentals

Common Selectors

• Type Selectors: em {color: blue; }

• Class Selectors: .wrapper {background-color: #CFC;}

• ID Selectors: #content {width:960px;}

• Descendant Selectors: p em {color:red;}

Page 13: CSS Fundamentals

Advanced Selectors

• Child Selectors: div>em {color:red;}

• Universal Selector: * {color:red;}

• Adjacent Sibling: h1+h3 {color:red;}

• Attribute Selectors: a[href=""],img[alt] {color:red;}

Page 14: CSS Fundamentals

Clean HTML is Crucial• DOM (Document Object Model)

• The Order of Things

Page 15: CSS Fundamentals

Pseudo Elements

• Pseudo Classes: :hover,:first-child

• Pseudo Elements: :first-line, :first-letter

• Insertion Elements: :before, :after

Page 16: CSS Fundamentals

Multiple Class Selectors

• You can combine multiple classes by separating them by spaces

"wrapper mod"

Page 17: CSS Fundamentals

Class Shortcuts

• Font

• Background

• Border

Page 18: CSS Fundamentals

The generic Tags

• Span-Inline

• DIV-Block Level

Page 19: CSS Fundamentals

The Box Model• Inline vs Block

• Margin

• Border

• Padding

Page 20: CSS Fundamentals

Floating

• To the Right or to the Left

• The container problem

• Fixing it with the mod class in html5reset

Page 21: CSS Fundamentals

Positioning

• Static-Normal positioning of objects

• Fixed-Fixed to the browser window

• Relative-Relative to it's current position, but can be moved

• Absolute-Relative to the last relatively positioned object, if one is not present, then works like Fixed...relative to the window.

• Z-index

Page 22: CSS Fundamentals

The End