you and your stylesheet

16
You and Your Stylesheet Virginia DeBolt BlogHer 09

Upload: virginia-debolt

Post on 04-Jul-2015

2.770 views

Category:

Technology


2 download

DESCRIPTION

A brief program on basics of blog CSS for beginners presented at the BlogHer09 Geek Lab.

TRANSCRIPT

Page 1: You and Your Stylesheet

You and Your Stylesheet

Virginia DeBolt

BlogHer 09

Page 2: You and Your Stylesheet

30 Minute Goals

• Talk about what CSS can do

• Talk about what a style rule looks like

• Talk about how to identify the style that matches the part of your page you want to style

• Answer your specific questions

Page 3: You and Your Stylesheet

What CSS can Do

• Set color and background color for any element

• Set font and font size for any element

• Set margins, borders and padding around any element

• Create layouts

• Create list appearance

• Create link appearance

• And more!

Page 4: You and Your Stylesheet

A CSS rule tells the browser how to render the HTML

div#content {font-family: Frutiger, Univers, "Helvetica Neue", arial, helvetica, sans-serif;font-size: 1em;line-height: 1.4;background:#fff;color:#000;margin:0 1em;padding:0 1em 0 0;

}

Page 5: You and Your Stylesheet

The Selector selects the element to style

div#content {font-family: Frutiger, Univers, "Helvetica Neue", arial, helvetica, sans-serif;font-size: 1em;line-height: 1.4;background:#fff;color:#000;margin:0 1em;padding:0 1em 0 0;

}

Page 6: You and Your Stylesheet

The declaration is inside {}

div#content {font-family: Frutiger, Univers, "Helvetica Neue",

arial, helvetica, sans-serif;font-size: 1em;line-height: 1.4;background:#fff;color:#000;margin:0 1em;padding:0 1em 0 0;

}

Page 7: You and Your Stylesheet

The property is a property of the element you are styling

div#content{font-family: Frutiger, Univers, "Helvetica Neue",

arial, helvetica, sans-serif;font-size: 1em;line-height: 1.4;background:#fff;color:#000;margin:0 1em;padding:0 1em 0 0;

}

Page 8: You and Your Stylesheet

The value sets how you want each property of the selector to look

div#content{font-family: Frutiger, Univers, "Helvetica Neue",

arial, helvetica, sans-serif;font-size: 1em;

line-height: 1.4;background:#fff;color:#000;margin:0 1em;padding:0 1em 0 0;

}

Page 9: You and Your Stylesheet

How can you figure out which selector to change?

Out of all the notes on the piano which one do you press?

Out of all the selectors and rules in the stylesheet, which one do you change?

Page 10: You and Your Stylesheet

Figuring out the Selectors with Web Developer Toolbar in Firefox

Page 11: You and Your Stylesheet

Figuring out the selectors with View Source

<div id="container">

<div id="content" class="hfeed”>

<div id="post-2819" class="hentryp1 post publish author-vdebolt category-blogher category-news-politics category-socialmedia category-twitter y2009 m06 d30 h04">

<h2 class="entry-title"><a href="http://www.webteacher.ws/2009/06/30/spreading-the-news/" title="Permalink to Spreading the News" rel="bookmark">Spreading the News</a></h2>

<div class="entry-date"><abbr class="published" title="2009-06-30T07:18:37-0400">Tuesday, June 30, 2009</abbr></div>

<div class="entry-content">

<p>Remember how remarkable it seemed several months ago when a plane sat down in the Hudson River and the first news and photos of the crash came from Twitter? Then the fly ash spill in TVA&#8217;s Kingston plant was covered first on Twitter. That was about the time that articles about how the old media just didn&#8217;t get digital media started appearing.</p>

Page 12: You and Your Stylesheet

Sometimes several selectors have the same rule

body.single h2.entry-title, body.page h2.entry-title, body.search h2.entry-title {

margin:1em 0 -0.5em;

}

A comma separated list of selectors—all follow the same rule.

Page 13: You and Your Stylesheet

Sometimes selectors get really specific

div.entry-content cite, div.comments ol.commentlist cite {

border-bottom:1px dotted #999;

cursor:help;

}

Selects any cite element that is a descendant of an ol element with a class attribute that contains the word commentlist that is a descendant of a div element with a class attribute that contains the word comments.

Page 14: You and Your Stylesheet

When you are trying to change something, you may need to get really specific too.

ol {} not specific enough?

Try div.entry-content ol {} instead.

.small {} not specific enough?

Try div#content p.small

Page 15: You and Your Stylesheet

Let’s talk about your problems

Questions?