you and your stylesheet
DESCRIPTION
A brief program on basics of blog CSS for beginners presented at the BlogHer09 Geek Lab.TRANSCRIPT
You and Your Stylesheet
Virginia DeBolt
BlogHer 09
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
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!
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;
}
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;
}
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;
}
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;
}
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;
}
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?
Figuring out the Selectors with Web Developer Toolbar in Firefox
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’s Kingston plant was covered first on Twitter. That was about the time that articles about how the old media just didn’t get digital media started appearing.</p>
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.
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.
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
Let’s talk about your problems
Questions?
Resources
• CSS cascade - a simple step-by-step presentation: http://www.maxdesign.com.au/2009/06/30/css-cascade/
• Web Teacher Tips: http://www.webteacher.ws/web-teacher-tips-and-tutorials/
• CSS: The Definitive Guide by Eric A. Meyer, O’Reilly, 2007