<?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>Saffron Stroke - Your Web Design Resource &#187; CSS tips</title>
	<atom:link href="http://www.saffronstroke.com/tag/CSS-tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.saffronstroke.com</link>
	<description>Design Blog</description>
	<lastBuildDate>Wed, 11 Jan 2012 06:36:24 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Class Selectors</title>
		<link>http://www.saffronstroke.com/2009/08/21/class-selectors/</link>
		<comments>http://www.saffronstroke.com/2009/08/21/class-selectors/#comments</comments>
		<pubDate>Fri, 21 Aug 2009 16:24:22 +0000</pubDate>
		<dc:creator>Minal</dc:creator>
				<category><![CDATA[CSS Hacks, Tips and Tricks]]></category>
		<category><![CDATA[class selector]]></category>
		<category><![CDATA[classes]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[CSS tips]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[selectors]]></category>

		<guid isPermaLink="false">http://saffronstroke.com/?p=648</guid>
		<description><![CDATA[We learnt what &#8216;Element Selectors&#8217; are and how to group declarations and selectors, in our tutorial Element Selectors in CSS. But as you advance in HTML and CSS, you will need more specialized rules to style an element.  Apart from document elements (element selectors) there are two other types of selectors you can define on [...]]]></description>
				<content:encoded><![CDATA[<p>We learnt what &#8216;Element Selectors&#8217; are and how to group declarations and selectors, in our tutorial <a href="http://saffronstroke.com/2009/07/20/element-selectors-cs/">Element Selectors in CSS</a>. But as you advance in HTML and CSS, you will need more specialized rules to style an element.  Apart from document elements (element selectors) there are two other types of selectors you can define on your own. They are <strong>Class selectors</strong> and <strong>ID selectors</strong>.</p>
<p><strong>What are class selectors?</strong></p>
<p>A class selector is set of styles that you can apply to one or more elements. See these examples:</p>
<p>&lt;p class=”desc_text” &gt;Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor &lt;/p&gt;</p>
<p>&lt;h3&gt; Lorem ipsum dolor &lt;span class=”desc_text”&gt; sit amet, consectetur adipisicing elit, sed &lt;/span&gt; do eiusmod tempor &lt;/h3&gt;</p>
<p>A class ‘desc_text’ when applied to the paragraph element stylizes the entire paragraph whereas when applied to the span element stylizes only the spanned text.</p>
<p>Though we will learn more about the ID selector later, the main difference between the two is that class selectors can be used for multiple selectors and ID selector can style a single element in the entire document.</p>
<p><strong>Defining class selector in CSS</strong></p>
<p>In CSS the class selector is preceded by a period ‘.’ followed by the class name and style definition. See below:</p>
<p>.desc_text {font-size: 10px; color: #cccccc; }</p>
<p>This kind of class selector could be applied to any element that matches the class attribute value ‘desc_text’.</p>
<p>You can also use the universal selector ‘*’ to define the class that matches any element in the document.</p>
<p>*.desc_text {font-size: 10px; color: #cccccc;}</p>
<p>But this one;</p>
<p>p.desc_text {font-size: 10px; color: #cccccc; }</p>
<p>will match any paragraph elements that have the class attribute containing the word ‘desc_text’. In the above example the span element would not match this class and hence the styles would not be applied. So this kind of rule applies only to a specific type of element.</p>
<p><strong>Combination of general class selector and element-specific class selector</strong></p>
<p>.desc_text { font-size: 10px; }</p>
<p>span.desc_text { color: #cccccc ;}</p>
<p>First declaration is an example of general class selector and the second one is of element specific class selector. You can declare both and use them together. The output of the above example would be as shown below:</p>
<p><img class="alignnone size-full wp-image-649" title="Example" src="http://www.saffronstroke.com/wp-content/uploads/2009/08/untitled.jpg" alt="Example" width="438" height="60" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.saffronstroke.com/2009/08/21/class-selectors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Universal Selector in CSS2</title>
		<link>http://www.saffronstroke.com/2009/08/14/universal-selector-in-css2/</link>
		<comments>http://www.saffronstroke.com/2009/08/14/universal-selector-in-css2/#comments</comments>
		<pubDate>Fri, 14 Aug 2009 13:39:18 +0000</pubDate>
		<dc:creator>Minal</dc:creator>
				<category><![CDATA[CSS Hacks, Tips and Tricks]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[CSS tips]]></category>
		<category><![CDATA[DHTML]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[selector]]></category>
		<category><![CDATA[tricks]]></category>
		<category><![CDATA[universal selector]]></category>
		<category><![CDATA[XHTML]]></category>

		<guid isPermaLink="false">http://saffronstroke.com/?p=635</guid>
		<description><![CDATA[CSS2 had introduced a new selector, the universal selector to match any element in your page. The selector is indicated as an asterisk &#8216;*&#8217;. The universal selector could be used to list every element in your page. For example, * {font-size: 12px} This declaration would set the font size of all the elements used in [...]]]></description>
				<content:encoded><![CDATA[<p>CSS2 had introduced a new selector, the universal selector to match any element in your page. The selector is indicated as an asterisk &#8216;*&#8217;. The universal selector could be used to list every element in your page.<br />
For example,</p>
<p>* {font-size: 12px}</p>
<p>This declaration would set the font size of all the elements used in your document to 12px.</p>
<p>NOTE: Even though the universal selector is one handy option, consider the specificity of other selectors for it to work properly.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.saffronstroke.com/2009/08/14/universal-selector-in-css2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Element Selectors in CSS</title>
		<link>http://www.saffronstroke.com/2009/07/20/element-selectors-cs/</link>
		<comments>http://www.saffronstroke.com/2009/07/20/element-selectors-cs/#comments</comments>
		<pubDate>Mon, 20 Jul 2009 06:52:50 +0000</pubDate>
		<dc:creator>Minal</dc:creator>
				<category><![CDATA[CSS Hacks, Tips and Tricks]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[CSS tips]]></category>
		<category><![CDATA[DHTML]]></category>
		<category><![CDATA[element]]></category>
		<category><![CDATA[grouping selectors]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[selectors]]></category>
		<category><![CDATA[techniques]]></category>
		<category><![CDATA[XHTML]]></category>

		<guid isPermaLink="false">http://saffronstroke.com/?p=597</guid>
		<description><![CDATA[Why is CSS preferred by all the designers? Well that is because of its ability to separate presentation from the content and most importantly its power to edit the document style by changing a single line of code. Don&#8217;t believe me? Find it yourself! An element selector is an HTML element. There are other types [...]]]></description>
				<content:encoded><![CDATA[<p>Why is CSS preferred by all the designers? Well that is because of its ability to separate presentation from the content and most importantly its power to edit the document style by changing a single line of code. Don&#8217;t believe me? Find it yourself!</p>
<p>An element selector is an HTML element. There are other types of selectors too, which we will explore later. So the element selectors are the most basic selectors in your document structure. html, body, p, div, span, headings, etc are all different types of element selectors of a document. We can apply certain rules to them to stylize these selectors. For example, if we want all the paragraphs to be displayed in red color, we can do that by;</p>
<p>p { color: red}</p>
<p>Or if we want the heading 2 to appear with a gray background;</p>
<p>h2 { background-color: gray}</p>
<p><strong>Grouping multiple declarations</strong></p>
<p>We saw how to apply a single declaration to an element selector. But you can have multiple declarations in the same rule. See this example:</p>
<p>p { color: red; background-color: gray;}</p>
<p>In this rule, we have combined two declarations; (i) the font-color in all paragraphs to be red (ii) background color of all paragraphs to be gray. Semicolon is used as a separator between these declarations. If you notice, the last declaration is also followed by a semicolon. It is rather important to do so since browsers ignore the whitespaces in the style sheet. To make this clear see following example:</p>
<p>p { color: red; background-color: gray font-size: 10px; }</p>
<p>Since there is no ‘;’ after the value ‘gray’ for background-color, browsers check if the property has multiple values. But since font-size is not a valid value and background-color does not take multiple values, both the properties will be ignored. But note that the last declaration of the group need not end with a semicolon. For instance;</p>
<p>p { color: red; background-color: gray}</p>
<p>This will work absolutely fine in most of the browsers. But at a later stage, if you want to add some more declarations to the group, you must add a semicolon after this declaration, else it would ignored as shown in above example.</p>
<p><strong>Grouping Element Selectors</strong></p>
<p>We saw techniques to apply one or more styles to a single selector. But what if, you want to apply same style to more than one element selector. For instance, if you want heading 2 and paragraph both to be in red. It would be stupid of us if we write the same style for another element. There is a better way to do that;</p>
<p>h2, p { color: red}</p>
<p>In this example, we are using a comma to group two selectors, viz. &#8216;h3&#8242; and &#8216;p’. Similarly you can group multiple selectors. This way you generate fewer lines of styles in your style sheet which in turn makes it easier for you to find out selectors and styles at a later stage when your style sheet has numerous rules defined in it.</p>
<p><strong>Grouping multiple declarations with multiple selectors</strong></p>
<p>By now we grouped multiple declarations for a single selector and we also grouped multiple selectors with a single declaration. Now it’s turn to group multiple declarations, with multiple selectors. Confusing enough isn&#8217;t it! Well this example would make it clear;</p>
<p>h2, p {</p>
<p>                color: red;</p>
<p>                background-color: gray;</p>
<p>                font-size: 10px;</p>
<p>}</p>
<p>These were some powerful and effective techniques of CSS. We will learn more in our coming articles, but for now I hope you enjoyed reading this.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.saffronstroke.com/2009/07/20/element-selectors-cs/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
