<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>CSS Etc &#187; classes and IDs</title>
	<atom:link href="http://www.cssetc.com/tag/classes-and-ids/feed" rel="self" type="application/rss+xml" />
	<link>http://www.cssetc.com</link>
	<description>CSS Web Design - CSS Coding - PSD to HTML - Tube Site Design - WordPress Templates - CSSetc.com for all your CSS needs!</description>
	<lastBuildDate>Mon, 02 Nov 2009 04:46:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>IDs and Classes</title>
		<link>http://www.cssetc.com/2009/basic-css/ids-and-classes.html</link>
		<comments>http://www.cssetc.com/2009/basic-css/ids-and-classes.html#comments</comments>
		<pubDate>Mon, 02 Nov 2009 04:46:09 +0000</pubDate>
		<dc:creator>Robyn</dc:creator>
				<category><![CDATA[Basic CSS]]></category>
		<category><![CDATA[basics]]></category>
		<category><![CDATA[classes and IDs]]></category>
		<category><![CDATA[reference]]></category>
		<category><![CDATA[structure]]></category>
		<category><![CDATA[tutorials]]></category>

		<guid isPermaLink="false">http://www.cssetc.com/wpt-284/?p=361</guid>
		<description><![CDATA[Once you understand the basic structure of CSS &#8211; selector {property: value;} &#8211; you can begin using it to style elements in your html documents. There are certain elements in html that we use all the time; p for paragraphs, h1 h2 h3 for headings, ol and ul for lists&#8230;all of these things can be [...]]]></description>
			<content:encoded><![CDATA[<p>Once you understand the <a href="http://www.cssetc.com/wpt-284/2009/basic-css/a-beginners-look-at-css.html">basic structure of CSS</a> &#8211; selector {property: value;} &#8211; you can begin using it to style elements in your <span class="caps">html</span> documents. There are certain elements in <span class="caps">html</span> that we use all the time; p for paragraphs, h1 h2 h3 for headings, ol and ul <span id="more-361"></span>for lists&#8230;all of these things can be styled using that syntax. Font color and size, padding, margins, positioning and anything else that you would use to style these elements can be incorporated into your Cascading Style Sheet. The fun part comes when you start designating your own selectors, and that&#8217;s what classes and IDs are for.</p>
<div class="firstline text120">Classes</div>
<p>In CSS, a class is defined by using <span class="boldtext">.classname</span> in the stylesheet, where classname is whatever title you choose to name the element. For example, in the above sentence, I used &lt;span class=&#8221;boldtext&#8221;&gt;<span class="boldtext">.classname</span>&lt;span&gt; to apply a bold font to the selection. The corresponding CSS code would look like this:
<div class="padbottom7 boldtext">.boldtext {font-weight: bold;}</div>
<p>Every time I used the class <span class="boldtext">.boldtext</span> in my document, the enclosed text will be bold. Pretty simple!</p>
<p>By using the ability to assign your own classes, you can have multiple elements share the same styling throughout the page.</p>
<p>Classes can be used more than once in a single page &#8211; in fact, the same class can be used as many times as you want.</p>
<div class="firstline text120">IDs</div>
<p>Giving an element an ID is the same idea, with a couple of differences. With an ID, you replace &#8216;.&#8217; with &#8216;#&#8217; and end up with this:
<div class="padbottom7 boldtext">#boldtext {font-weight: bold;}</div>
<p>which will do the same thing as the class did &#8211; style the element with a bold font. The other difference, and this is important! &#8211; is that an ID can only be used once within a page. I use IDs a lot for structual elements, like headers and footers, because those elements are generally only used once in an <span class="caps">html</span> page.</p>
<p>If you think of an ID as something unique, like a person&#8217;s name, and classes as something that has more than one, like a class of people, then you&#8217;ll remember how to use them in writing your CSS.</p>
<p>Now you may be asking &#8211; what&#8217;s the difference between using <span class="boldtext">&lt;span class=&#8221;bold&#8221;&gt;</span> in a stylesheet and <span class="boldtext">&lt;span style=&#8221;bold&#8221;&gt;</span> in your <span class="caps">html</span>? You still have to type it into your markup every time you want the text to be bold, right? Well, that is true, but once you get into using multiple values for the same element you&#8217;ll see what a difference CSS can make. Imagine that you not only want that text <span class="boldtext">bold</span>, but you want it to be <span class="blue1">bold, blue and in Comic Sans font</span>. You can combine all of those attributes into one class and save yourself the headache of writing out all three styles every time you want that particular styling.</p>
<p>Your CSS would look like this:
<div class="padbottom7 boldtext">.blue1 {font-style: bold; color: #0000ff; font-family: &#8220;Comic Sans MS&#8221;;}</div>
<p>and your <span class="caps">html</span> would look like this:
<div class="padbottom7 boldtext">&lt;span class=&#8221;blue1&#8243;&gt;<span class="blue1">here is your styled text</span>&lt;span&gt;</div>
<p> We&#8217;ll get further into multiple properties in another post.</p>
<p>Trust me, when you&#8217;re adding margins, padding, colors, backgrounds, positioning and font attributes all to one element, you&#8217;ll love using CSS!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cssetc.com/2009/basic-css/ids-and-classes.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
