<?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>csslearn.com &#187; CSS Tutorials</title>
	<atom:link href="http://csslearn.com/category/css-tutorials/feed" rel="self" type="application/rss+xml" />
	<link>http://csslearn.com</link>
	<description>learn style with style</description>
	<lastBuildDate>Mon, 01 Mar 2010 02:17:37 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Styling for Print</title>
		<link>http://csslearn.com/styling-for-print</link>
		<comments>http://csslearn.com/styling-for-print#comments</comments>
		<pubDate>Mon, 01 Mar 2010 02:17:37 +0000</pubDate>
		<dc:creator>kunal</dc:creator>
				<category><![CDATA[CSS Advanced]]></category>
		<category><![CDATA[CSS Examples]]></category>
		<category><![CDATA[CSS Tutorials]]></category>

		<guid isPermaLink="false">http://csslearn.com/?p=152</guid>
		<description><![CDATA[You can use a specific style sheet to style content for  print.You know the differences between length units used for a computer screen  and length units used for print. This is one of the key reasons that separate  style sheets for print exist. Specifying measurements designated for computer  screens, such as [...]


Related posts:<ol><li><a href='http://csslearn.com/using-stylesheets' rel='bookmark' title='Permanent Link: Using Stylesheets'>Using Stylesheets</a> <small>You can place styles in three locations: stylesheets, &lt;style&gt;, and...</small></li>
<li><a href='http://csslearn.com/styling-text-using-css' rel='bookmark' title='Permanent Link: Styling text using CSS'>Styling text using CSS</a> <small>HTML is intended as a structural markup language, but the...</small></li>
<li><a href='http://csslearn.com/adding-styles-to-a-web-page' rel='bookmark' title='Permanent Link: Adding styles to a web page'>Adding styles to a web page</a> <small>The most common (and useful) method of applying CSS rules...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>You can use a specific style sheet to style content for  print.You know the differences between length units used for a computer screen  and length units used for print. This is one of the key reasons that separate  style sheets for print exist. Specifying measurements designated for computer  screens, such as pixel units, can potentially be inconsistent in printed  documents, whereas real-world, absolute length units, such as inches,  centimeters, points, and so on are ideally suited for print.</p>
<p>A style sheet written explicitly for print enables developers to  exclude irrelevant portions of a web document from the printed version. For  example, no document navigation is required in a printed version. Additionally,  because color documents have some expense associated with them, depending on the  type of printer and what type of ink or toner the printer uses, it is also often  better to exclude background images or other aspects of the design that result  in greater consumption of expensive ink or toner. For these reasons, print  versions of web documents are often simplified to simple black and white  productions of the original document. Only foreground images relevant to the  document are retained. In fact browsers, by default, strip out all background  images and color; to print these, the user must specifically enable them before  printing.</p>
<p>CSS 2 provides several properties for controlling the presentation  of paged media, although at the time of this writing a sparse selection of those  properties is actually implemented in current browsers. CSS 2 properties control  such things as where page breaks occur, the size of the page margins, and the  size of the page itself. In this area, Opera boasts the best support for the CSS  2 paged media properties; I focus on only the features that have the best  support.</p>
<h2><a name="1311"></a><a name="ch13lev1"></a>Applying Styles  Based on Media</h2>
<p>In order to print in CSS, you need a way of differentiating  styles intended for print from styles intended for the computer screen. CSS can  apply to a variety of documents, not just (X)HTML, and CSS can be used on a  variety of different devices and media. <a name="1312"></a><a name="IDX-"></a></p>
<p>To target different media, you use the media attribute, which is applied to the &lt;link /&gt; element, or the &lt;style&gt; element. Or, from within a style sheet, you can  target different media using @media rules. You see  examples of these later in this section. First, let’s examine the different  types of media that CSS can theoretically be applied to. The different types of  media are outlined in the following table.</p>
<div>
<table id="nr-N58" border="1"><a target="_blank"></a></p>
<thead>
<tr valign="top">
<th align="left" valign="top" scope="col"><strong>Media </strong></th>
<th align="left" valign="top" scope="col"><strong>Purpose</strong></th>
</tr>
</thead>
<tbody>
<tr valign="top">
<td align="left" valign="top">all</td>
<td align="left" valign="top">Suitable for all devices.</td>
</tr>
<tr valign="top">
<td align="left" valign="top">braille</td>
<td align="left" valign="top">Intended for Braille tactical feedback devices.</td>
</tr>
<tr valign="top">
<td align="left" valign="top">embossed</td>
<td align="left" valign="top">Intended for paged Braille printers.</td>
</tr>
<tr valign="top">
<td align="left" valign="top">handheld</td>
<td align="left" valign="top">Intended for handheld devices.</td>
</tr>
<tr valign="top">
<td align="left" valign="top">print</td>
<td align="left" valign="top">Intended for presentation to a printer (in a browser, use  print preview to view the print style sheet).</td>
</tr>
<tr valign="top">
<td align="left" valign="top">projection</td>
<td align="left" valign="top">Intended for projected presentations.</td>
</tr>
<tr valign="top">
<td align="left" valign="top">screen</td>
<td align="left" valign="top">Intended for presentation on a color computer screen.</td>
</tr>
<tr valign="top">
<td align="left" valign="top">speech | aural</td>
<td align="left" valign="top">Intended for presentation to a speech synthesizer (called  aural in CSS 2 and speech in CSS 2.1).</td>
</tr>
<tr valign="top">
<td align="left" valign="top">tty</td>
<td align="left" valign="top">Intended for media using a fixed-pitch character grid (such  as teletypes, terminals, or portable devices with limited display capabilities).</td>
</tr>
<tr valign="top">
<td align="left" valign="top">tv</td>
<td align="left" valign="top">Intended for television (low resolution, low color, limited  scrollability).</td>
</tr>
</tbody>
</table>
</div>
<p>PC and Mac browsers recognize only screen, print, and all values.</p>
<p>As you can see in the preceding table, CSS can target a wide  variety of media types. For the purposes of the discussion, you need only be concerned with the screen,  print, and all media. Each  medium can be supplied as a value to the media  attribute. For example, if you wanted a style sheet to apply only to styles  presented in a PC or Mac browser, you would add the attribute media=&#8221;screen&#8221; to either the &lt;link  /&gt; or &lt;style&gt; elements. A demonstration  appears in</p>
<p>p{<br />
width:200px;<br />
height: 200px;<br />
padding: 10px<br />
margin: 10px;<br />
font: 12px sans-serif;<br />
}</p>
<p>In above example you see  that some basic styles have been applied to the &lt;p&gt; element, nothing fancy, or really of particular  interest.</p>
<p>In below you see one  new addition, the media=&#8217;screen&#8217; attribute, is applied  to the &lt;link /&gt; element, which tells the browser  that the styles are intended for onscreen display only. In 3rd you don’t notice anything extraordinary; you see a  &lt;p&gt; element with the styles applied as you would  expect. The effects of the addition of the media=&#8217;screen&#8217; attribute become noticeable when you go to  print the document. 4th shows  what the print preview looks like.</p>
<p><img src="file:///C:/Documents%20and%20Settings/Kunal%20Mamtura/Desktop/sam1.jpg" alt="" /></p>
<p><img src="file:///C:/Documents%20and%20Settings/Kunal%20Mamtura/Desktop/sam1.jpg" alt="" /><img src="file:///C:/Documents%20and%20Settings/Kunal%20Mamtura/Desktop/sam1.jpg" alt="" /><img src="file:///C:/Documents%20and%20Settings/Kunal%20Mamtura/Desktop/sam1.jpg" alt="" /><img src="file:///C:/Documents%20and%20Settings/Kunal%20Mamtura/Desktop/sam1.jpg" alt="" /><img src="file:///C:/Documents%20and%20Settings/Kunal%20Mamtura/Desktop/sam1.jpg" alt="" /></p>
<p><a href="http://csslearn.com/wp-content/uploads/2010/03/sam11.jpg"><img class="aligncenter size-full wp-image-156" title="sam1" src="http://csslearn.com/wp-content/uploads/2010/03/sam11.jpg" alt="" width="600" height="332" /></a></p>
<p><a href="http://csslearn.com/wp-content/uploads/2010/03/sam21.jpg"><img class="aligncenter size-full wp-image-157" title="sam2" src="http://csslearn.com/wp-content/uploads/2010/03/sam21.jpg" alt="" width="500" height="271" /></a></p>
<p><a href="http://csslearn.com/wp-content/uploads/2010/03/sam31.jpg"><img class="aligncenter size-full wp-image-158" title="sam3" src="http://csslearn.com/wp-content/uploads/2010/03/sam31.jpg" alt="" width="707" height="284" /></a></p>
<p>In 4th image, you see what’s happened  here &#8211; since the styles only apply to onscreen display, they aren’t applied to  the print version of the document. If you would have included media=&#8217;all&#8217;, the styles would be present in the printed  version. Or, you could create a style sheet that applies to print exclusively,  by using the media=&#8217;print&#8217; attribute. In the next  section I discuss the @media rule, which allows you to  make medium-based distinctions from within the style sheet.</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fcsslearn.com%2Fstyling-for-print&amp;linkname=Styling%20for%20Print"><img src="http://csslearn.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>

<p>Related posts:<ol><li><a href='http://csslearn.com/using-stylesheets' rel='bookmark' title='Permanent Link: Using Stylesheets'>Using Stylesheets</a> <small>You can place styles in three locations: stylesheets, &lt;style&gt;, and...</small></li>
<li><a href='http://csslearn.com/styling-text-using-css' rel='bookmark' title='Permanent Link: Styling text using CSS'>Styling text using CSS</a> <small>HTML is intended as a structural markup language, but the...</small></li>
<li><a href='http://csslearn.com/adding-styles-to-a-web-page' rel='bookmark' title='Permanent Link: Adding styles to a web page'>Adding styles to a web page</a> <small>The most common (and useful) method of applying CSS rules...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://csslearn.com/styling-for-print/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using Shorthand Properties in CSS</title>
		<link>http://csslearn.com/using-shorthand-properties-in-css</link>
		<comments>http://csslearn.com/using-shorthand-properties-in-css#comments</comments>
		<pubDate>Tue, 15 Dec 2009 19:20:55 +0000</pubDate>
		<dc:creator>kunal</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[CSS Advanced]]></category>
		<category><![CDATA[CSS Tutorials]]></category>

		<guid isPermaLink="false">http://csslearn.com/?p=143</guid>
		<description><![CDATA[Your body rule should now look like this:
body {
font: 100%/1.5 &#8220;Helvetica Neue&#8221;, Helvetica, Arial, sans-serif;
background: #7F98C3;
margin: 0;
padding: 0;
text-align: center;
color: #000000;
}
If you look at the font property, you may notice that your CSS may not look like ours. If you have individual font values on each line instead of all in one line, it is due [...]


Related posts:<ol><li><a href='http://csslearn.com/working-with-css-shorthand-for-boxes' rel='bookmark' title='Permanent Link: Working with CSS shorthand for boxes'>Working with CSS shorthand for boxes</a> <small>This is something that is useful to get to grips...</small></li>
<li><a href='http://csslearn.com/css-shorthand-for-font-properties' rel='bookmark' title='Permanent Link: CSS shorthand for font properties'>CSS shorthand for font properties</a> <small>The CSS properties discussed so far can be written in...</small></li>
<li><a href='http://csslearn.com/using-property-values' rel='bookmark' title='Permanent Link: Using Property Values'>Using Property Values</a> <small>Property values come in the following forms: constant text, constant...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Your body rule should now look like this:<br />
<em><strong>body {<br />
font: 100%/1.5 &#8220;Helvetica Neue&#8221;, Helvetica, Arial, sans-serif;<br />
background: #7F98C3;<br />
margin: 0;<br />
padding: 0;<br />
text-align: center;<br />
color: #000000;<br />
}<br />
</strong></em>If you look at the font property, you may notice that your CSS may not look like ours. If you have individual font values on each line instead of all in one line, it is due to the way the CSS preferences are set in Dreamweaver: we keep our preferences set to write shorthand. So what in the world is shorthand anyway? Simply put, shorthand lets you specify several values with a single property. It can be quite a space saver in CSS documents and once you get used to it,<br />
it makes it much easier to read your pages. Order is generally quite important when using shorthand, because<br />
one property name may have several values following it. Let’s look quickly at a couple of shorthand examples, beginning with the font property. There are six possible values for font: font-style, font-variant, font-weight, font-size, line-height, and font-family. If one of these values is not declared, the default for the value is used. In the case of our style sheet, you can see that we declared the font-size, line-height, and font-family. This means the other three properties are left at their default values. Our shorthand declaration equals this block of code:<br />
<em><strong>font-style: normal;<br />
font-variant: normal;<br />
font-weight: normal;<br />
font-size: 100%;<br />
line-height: 1.5;<br />
font-family: &#8220;Helvetica Neue&#8221;, Helvetica, Arial, sans-serif;<br />
</strong></em></p>
<p>The shorthand for applying background values is similar to font shorthand. The property is called background and it has fi ve possible values: background-color, background-image, background repeat, background-attachment, and background-position. Thus,<br />
<em><strong>background: #7F98C3 url(images/body_back.jpg) repeat-y left<br />
top; is equal to:<br />
background-color: #7F98C3;<br />
background-image: url(images/body_back.jpg);<br />
background-repeat: repeat-y;<br />
background-attachment: scroll;<br />
background-position: left top;<br />
</strong></em>Border is a similar property. It allows us to set the width, style and color of the borders of a box. It does not allow us to make one of the sides different than the other, however. To do that, we need to declare that value separately. So for instance, if we want to set the width of the left side border of our box to be 2px and the rest to be 1px, we could write it like this:<em><strong><br />
border: 1px solid #000;<br />
border-left-width: 2px;</strong></em><br />
The first line sets the entire box to have a 1px black border with a solid style. The second line overrides the width of the left border. Remember the cascade—to override the 1px border, the 2px border must come after it.<br />
Font, background, and border are the most common mixed value shorthand properties. Two other shorthand properties that we’ll use throughout the book are margin and padding. The shorthand for these properties allows<br />
us to set all four sides of the box at once. Both properties are written in the same way: the specifi c order is top, right, bottom, left. People use different tricks to remember the order: you can think of the rule as trouble, from the acronym TRBL, or more simply, as clockwise (start at the top and moving around the box). After years of experience, we still  find ourselves using our tricks of choice as we write our code.</p>
<p>For example, margin: 0 20px 10px 15px; is equal to:<br />
<strong><em>margin-top: 0;<br />
margin-right: 20px;<br />
margin-bottom: 10px;<br />
margin-left: 15px;</em><br />
</strong>When the values of all four sides are the same, only one value needs to be used since it applies to all four sides: margin: 0; Notice there is no unit of measurement after the 0. This is because, no matter what unit you place after zero—pixels, percent, em units—the value is still the same, zero. If you’re using equivalent top and bottom values as well as equal<br />
side values, you can use only two values: margin: 10px 15px; This indicates that the top and bottom values are 10px and the right and left are 15px.</p>
<p>Finally, if your top and bottom sides have different values from each other, but the sides are the same, you can use three values in your shorthand: margin: 0 20px 15px; This tells the browser to render 0 on the top margin, 20px on the<br />
right margin, 15px on the bottom and the lack of a fourth value indicates that the left side is equivalent to the right side. So it’s 20px as well. As you can see, shorthand is cool and it’s absolutely the way we want to write our code. It’s much too handy to not use, so throughout the rest of the book, we’ll be using shorthand. Let’s make sure you can do the same!</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fcsslearn.com%2Fusing-shorthand-properties-in-css&amp;linkname=Using%20Shorthand%20Properties%20in%20CSS"><img src="http://csslearn.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>

<p>Related posts:<ol><li><a href='http://csslearn.com/working-with-css-shorthand-for-boxes' rel='bookmark' title='Permanent Link: Working with CSS shorthand for boxes'>Working with CSS shorthand for boxes</a> <small>This is something that is useful to get to grips...</small></li>
<li><a href='http://csslearn.com/css-shorthand-for-font-properties' rel='bookmark' title='Permanent Link: CSS shorthand for font properties'>CSS shorthand for font properties</a> <small>The CSS properties discussed so far can be written in...</small></li>
<li><a href='http://csslearn.com/using-property-values' rel='bookmark' title='Permanent Link: Using Property Values'>Using Property Values</a> <small>Property values come in the following forms: constant text, constant...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://csslearn.com/using-shorthand-properties-in-css/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Cascade Order</title>
		<link>http://csslearn.com/using-cascade-order</link>
		<comments>http://csslearn.com/using-cascade-order#comments</comments>
		<pubDate>Sun, 06 Dec 2009 19:05:02 +0000</pubDate>
		<dc:creator>kunal</dc:creator>
				<category><![CDATA[CSS Advanced]]></category>
		<category><![CDATA[CSS Basic]]></category>
		<category><![CDATA[CSS Examples]]></category>
		<category><![CDATA[CSS Tutorials]]></category>

		<guid isPermaLink="false">http://csslearn.com/?p=94</guid>
		<description><![CDATA[CSS allows you to assign the same rule to the same element multiple times. I call these competing rules. Browsers use the cascading order to determine which rule in a set of competing rules gets applied. For example, a browser assigns default rules to each element. When you assign a rule to an element, your [...]


Related posts:<ol><li><a href='http://csslearn.com/css-syntax-syntax-details' rel='bookmark' title='Permanent Link: CSS Syntax &#038; Syntax Details'>CSS Syntax &#038; Syntax Details</a> <small>CSS syntax is easy. A stylesheet contains styles; a style...</small></li>
<li><a href='http://csslearn.com/using-shorthand-properties-in-css' rel='bookmark' title='Permanent Link: Using Shorthand Properties in CSS'>Using Shorthand Properties in CSS</a> <small>Your body rule should now look like this: body {...</small></li>
<li><a href='http://csslearn.com/types-of-css-selectors' rel='bookmark' title='Permanent Link: Types of CSS selectors'>Types of CSS selectors</a> <small>In the previous example, the most basic style of selector...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>CSS allows you to assign the same rule to the same element multiple times. I call these competing rules. Browsers use the cascading order to determine which rule in a set of competing rules gets applied. For example, a browser assigns default rules to each element. When you assign a rule to an element, your rule competes with the default rule, but since it has a higher cascading priority, it overrides the default rule.</p>
<p>The cascading order divides rules into six groups based on the type of selector used in the rule. A rule in a higher-priority group overrides a competing rule in a lower-priority group. Groups are organized by the specificity of their selectors. Selectors in lower-priority groups have less specificity than selectors in higher-priority groups.<br />
The guiding principle behind the cascade order is that general selectors set overall styles for a document and more specific selectors override the general selectors to apply specific styles.</p>
<p>For example, you may want to style all elements in a document with no bottom margin using *{margin-bottom:0;}. You may also want to style all paragraphs in a document with a bottom margin of 10 pixels using p{margin-bottom:10px;}. You may also want to style the few paragraphs belonging to the double-space class with a bottom margin of 2 ems using *.double-space{margin-bottom:2em;}. You may also want to style one paragraph with an<br />
extra-large bottom margin of 40 pixels using #paragraph3{margin-bottom:40px;}. In each of these cases, the cascade order ensures a more specific selector overrides a more general one.</p>
<p>Following are the six selector groups listed from highest to lowest priority:</p>
<p>1. The highest-priority group contains rules with !important added to them. They override all non-!important rules. For example, #i100{border:6px solid black!important;} takes priority over #i100{border:6px solid black;}.</p>
<p>2. The second-highest-priority group contains rules embedded in the style attribute. Since using the style attribute creates hard-to-maintain code, I do not recommend using it.</p>
<p>3. The third-highest-priority group contains rules that have one or more ID selectors. For example, #i100{border:6px solid black;} takes priority over *.c10{border:4px solid black;}.</p>
<p>4. The fourth-highest-priority group contains rules that have one or more class, attribute, or pseudo selectors. For example, *.c10{border:4px solid black;} takes priority over div{border:2px solid black;}.</p>
<p>5. The fifth-highest-priority group contains rules that have one or more element selectors. For example, div{border:2px solid black;} takes priority over *{border:0px solid black;}.</p>
<p>6. The lowest-priority group contains rules that have only a universal selector—for example, *{border:0px solid black;}.</p>
<p>When competing rules belong to the same selector group (such as both rules contain ID selectors), the type and number of selectors prioritize them further. A selector has higher priority when it has more selectors of a higher priority than a competing selector.</p>
<p>For example, #i100 *.c20 *.c10{} has a higher priority than #i100 *.c10 div p span em{}. Since both selectors contain an ID selector, they are both in the third-highest-priority group. Since the first has two class selectors and the second has only one class selector, the first has higher priority—even though the second has more selectors.</p>
<p>When competing rules are in the same selector group and have the same number and level of selectors, they are further prioritized by location. Any rule in a higher-priority location overrides a competing rule in a lower-priority location. (Again, this only applies when competing rules are in the same selector group and have the same number and level of selectors. Selector groups always take precedence over location groups.) The six locations are listed here from highest to lowest priority:</p>
<p>1. The highest-priority location is the &lt;style&gt; element in the head of the HTML document. For example, a rule in &lt;style&gt; overrides a competing rule in a stylesheet imported by an @import statement embedded within &lt;style&gt;.</p>
<p>2. The second-highest-priority location is a stylesheet imported by an @import statement embedded within the &lt;style&gt; element. For example, a rule in a stylesheet imported by an @import statement embedded within &lt;style&gt; overrides a competing rule in a stylesheet attached by a &lt;link&gt; element.</p>
<p>3. The third-highest-priority location is a stylesheet attached by a &lt;link&gt; element. For example, a rule in a stylesheet attached by a &lt;link&gt; element overrides a competing rule imported by an @import statement embedded within the stylesheet.</p>
<p>4. The fourth-highest-priority location is a stylesheet imported by an @import statement embedded within a stylesheet attached by a &lt;link&gt; element. For example, a rule imported by an @import statement embedded within a linked stylesheet overrides a competing rule in stylesheet attached by an end user.</p>
<p>5. The fifth-highest-priority location is a stylesheet attached by an end user. • An exception is made for !important rules in an end-user stylesheet. These rules are given the highest priority. This allows an end user to create rules to override competing rules in an author’s stylesheet.</p>
<p>6. The lowest-priority location is the default stylesheet supplied by a browser.</p>
<p>When multiple stylesheets are attached or imported at the same location level, the order in which they are attached determines the priority. Stylesheets attached later override stylesheets attached previously.</p>
<p>When competing rules are in the same selector group, have the same number and level of selectors, and have the same location level, rules listed later in the code override rules listed earlier.</p>
<p>In Example 1-7, each rule in the stylesheet is applied to the division element. Each rule applies a different border-width to &lt;div&gt;. Cascading order determines which rule actually gets applied. I sorted the styles in the stylesheet into cascading order from least to most important. As you can see from the screenshot, the browser applies the last rule to the &lt;div&gt;, which sets a 14-pixel border around the &lt;div&gt;. The browser applies this rule because it has the highest priority in the cascading order—it is an ID selector with !important attached to it.</p>
<p>Notice how ID selectors override class selectors, which in turn override element selectors, which in turn override the universal selector. Notice how !important gives selectors a whole new magnitude of importance. For example, the !important universal selector is more important than the un-!important ID selector!</p>
<p>Notice how border-style:none!important; is placed in the body and html selectors to prevent the universal selector * from putting a border around &lt;body&gt; and &lt;html&gt;. This also illustrates how element selectors override universal selectors.</p>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 1465px; width: 1px; height: 1px;">When multiple stylesheets are attached or imported at the same location level, the order<br />
in which they are attached determines the priority. Stylesheets attached later override<br />
stylesheets attached previously.<br />
When competing rules are in the same selector group, have the same number and level of<br />
selectors, and have the same location level, rules listed later in the code override rules listed<br />
earlier.<br />
In Example 1-7, each rule in the stylesheet is applied to the division element. Each rule<br />
applies a different border-width to &lt;div&gt;. Cascading order determines which rule actually gets<br />
applied. I sorted the styles in the stylesheet into cascading order from least to most important.<br />
As you can see from the screenshot, the browser applies the last rule to the &lt;div&gt;, which sets a<br />
14-pixel border around the &lt;div&gt;. The browser applies this rule because it has the highest priority<br />
in the cascading order—it is an ID selector with !important attached to it.</div>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fcsslearn.com%2Fusing-cascade-order&amp;linkname=Using%20Cascade%20Order"><img src="http://csslearn.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>

<p>Related posts:<ol><li><a href='http://csslearn.com/css-syntax-syntax-details' rel='bookmark' title='Permanent Link: CSS Syntax &#038; Syntax Details'>CSS Syntax &#038; Syntax Details</a> <small>CSS syntax is easy. A stylesheet contains styles; a style...</small></li>
<li><a href='http://csslearn.com/using-shorthand-properties-in-css' rel='bookmark' title='Permanent Link: Using Shorthand Properties in CSS'>Using Shorthand Properties in CSS</a> <small>Your body rule should now look like this: body {...</small></li>
<li><a href='http://csslearn.com/types-of-css-selectors' rel='bookmark' title='Permanent Link: Types of CSS selectors'>Types of CSS selectors</a> <small>In the previous example, the most basic style of selector...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://csslearn.com/using-cascade-order/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Property Values</title>
		<link>http://csslearn.com/using-property-values</link>
		<comments>http://csslearn.com/using-property-values#comments</comments>
		<pubDate>Sun, 06 Dec 2009 18:55:31 +0000</pubDate>
		<dc:creator>kunal</dc:creator>
				<category><![CDATA[CSS Basic]]></category>
		<category><![CDATA[CSS Examples]]></category>
		<category><![CDATA[CSS Tutorials]]></category>
		<category><![CDATA[css clear examples]]></category>
		<category><![CDATA[css guide]]></category>
		<category><![CDATA[css online]]></category>
		<category><![CDATA[css properties]]></category>

		<guid isPermaLink="false">http://csslearn.com/?p=92</guid>
		<description><![CDATA[Property values come in the following forms: constant text, constant numbers, lengths, percentages, functions, comma-delimited lists of values, and space-delimited series of values. Each property accepts one or more of these types of values. I have included all common types of values in Example 1-6. But first, I have listed them here along with an [...]


Related posts:<ol><li><a href='http://csslearn.com/using-shorthand-properties-in-css' rel='bookmark' title='Permanent Link: Using Shorthand Properties in CSS'>Using Shorthand Properties in CSS</a> <small>Your body rule should now look like this: body {...</small></li>
<li><a href='http://csslearn.com/using-cascade-order' rel='bookmark' title='Permanent Link: Using Cascade Order'>Using Cascade Order</a> <small>CSS allows you to assign the same rule to the...</small></li>
<li><a href='http://csslearn.com/css-syntax-syntax-details' rel='bookmark' title='Permanent Link: CSS Syntax &#038; Syntax Details'>CSS Syntax &#038; Syntax Details</a> <small>CSS syntax is easy. A stylesheet contains styles; a style...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Property values come in the following forms: constant text, constant numbers, lengths, percentages, functions, comma-delimited lists of values, and space-delimited series of values. Each property accepts one or more of these types of values. I have included all common types of values in Example 1-6. But first, I have listed them here along with an explanation:<br />
<em><strong>• color:black;</strong></em> assigns the constant value black to the color property. Most properties have unique constant values. For example, the color property can be assigned to over 170 constants that represent colors ranging from papayawhip to ThreeDDarkShadow.<br />
<em><strong>• background-color:</strong></em>white; assigns the constant value white to the background-color property. Notice that the following three rules do the same thing as this rule, but use different types of property values.<em><strong><br />
• background-color:</strong></em>rgb(100%,100%,100%); assigns the CSS function rgb() to background-color. rgb() takes three comma-delimited parameters between its parentheses, which specify the amount of red, green, and blue to use for the color. In this example, percentages are used. 100% of each color makes white.<br />
<em><strong>• background-color:</strong></em>rgb(255,255,255); assigns white to the background-color. In this case, values from 0 to 255 are used instead of percentages. The value 0 is no color. The value 255 equals 100% of the color. Using 255 for red, green, and blue makes white.<br />
<em><strong>• background-color:</strong></em>WindowInfoBackground; assigns the operating system color WindowInfoBackground to background-color. Notice how operating system color constants are in CamelCase.7<br />
<em><strong>• font-style:</strong></em>italic; assigns the constant value of italic to font-style. The font-style property also allows two other constant values: normal and oblique.<br />
<em><strong>• font-size:</strong></em>20px; assigns a length of 20 pixels to font-size. You can assign a variety of measurements to most properties including px (pixel), em (height of the font or font-size), ex (height of the letter “x”), pt (point, i.e., 1/72 of an inch), in (inch), cm (centimeter), mm (millimeter), and pc (pica, i.e., 12 points, or 1/6 of an inch).<br />
<em><strong>• font-family:</strong></em>&#8220;Century Gothic&#8221;, verdana, arial, sans-serif; assigns a commadelimited list of font names to font-family. If the first font name is unavailable, a browser uses the second, and so forth. The last font name should be one of the generic font names: serif, sans-serif, or monospace, which works in every browser. Whenever a font name contains a space, it must be enclosed in double quotes, such as &#8220;Century Gothic&#8221;.<br />
<em><strong>• line-height:</strong></em>150%; assigns 150% of the font-size to line-height.<br />
<em><strong>• margin:</strong></em>1em; assigns the size of the font to margin (i.e., font-size multiplied by 1).</p>
<p><em><strong>• border:</strong></em>4px double black; creates a black, 4-pixel, double-line border. Notice how border takes three space-delimited values that represent the border’s width, style, and color. The sequence of the values does not matter. border is a shortcut property for three properties: border-width, border-style, and border-color. There are several other<br />
shortcut properties including background, font, list-style, margin, and padding.<br />
<em><strong>• padding:</strong></em>0.25em; assigns one-quarter of the font size to padding (i.e., font-size multiplied by 0.25).<br />
<em><strong>• background-image:</strong></em>url(&#8220;gradient.jpg&#8221;); assigns the gradient.jpg image to background-image using the url function, which takes the URL of a file as its only parameter. I always put a URL in quotes, but you only have to if the URL contains whitespace.<br />
<em><strong>• background-repeat:</strong></em>repeat-x; assigns the constant repeat-x to background-repeat. Other background-repeat values include repeat-y, repeat, and no-repeat.<br />
<em><strong>• margin:</strong></em>0; assigns zero to margin. Zero is the only length that may be specified without a measurement. All other lengths must be immediately followed by a measurement, such as 1px, -1.5em, 2ex, 14pt, 0.5in, -3cm, 30mm, or 5pc.<br />
<em><strong>• font-weight:</strong></em>900; assigns the constant 900 to font-weight. This number is actually a constant. You can use the following constants for font-weight: normal, bold, bolder, lighter, 100, 200, 300, 400, 500, 600, 700, 800, or 900. (Note that browser support is poor for numerical font weights, generally treating 100 through 400 as normal and 500<br />
through 900 as bold. Furthermore, bolder and lighter is rarely supported by browsers and/or operating system fonts. Thus, I rarely use any value for font-weight other than normal or bold.)</p>
<p>Later in the post, I present a four-page chart called that lists all usable CSS properties and values. color is the only property in the chart that has an incomplete list of usable values. It shows 79 of the 170 color constants. I organized the 79 color constants into three groups that you may find useful: the 16 standard colors organized by hue, 35 common colors organized by hue from light to dark, and the 28 operating system colors. Throughout this book, I<br />
often use the color gold. I also use related hues such as wheat, orange, tomato, firebrick, and<br />
yellow.</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fcsslearn.com%2Fusing-property-values&amp;linkname=Using%20Property%20Values"><img src="http://csslearn.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>

<p>Related posts:<ol><li><a href='http://csslearn.com/using-shorthand-properties-in-css' rel='bookmark' title='Permanent Link: Using Shorthand Properties in CSS'>Using Shorthand Properties in CSS</a> <small>Your body rule should now look like this: body {...</small></li>
<li><a href='http://csslearn.com/using-cascade-order' rel='bookmark' title='Permanent Link: Using Cascade Order'>Using Cascade Order</a> <small>CSS allows you to assign the same rule to the...</small></li>
<li><a href='http://csslearn.com/css-syntax-syntax-details' rel='bookmark' title='Permanent Link: CSS Syntax &#038; Syntax Details'>CSS Syntax &#038; Syntax Details</a> <small>CSS syntax is easy. A stylesheet contains styles; a style...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://csslearn.com/using-property-values/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS Syntax &amp; Syntax Details</title>
		<link>http://csslearn.com/css-syntax-syntax-details</link>
		<comments>http://csslearn.com/css-syntax-syntax-details#comments</comments>
		<pubDate>Sun, 06 Dec 2009 18:42:36 +0000</pubDate>
		<dc:creator>kunal</dc:creator>
				<category><![CDATA[CSS Advanced]]></category>
		<category><![CDATA[CSS Basic]]></category>
		<category><![CDATA[CSS Examples]]></category>

		<guid isPermaLink="false">http://csslearn.com/?p=89</guid>
		<description><![CDATA[CSS syntax is easy. A stylesheet contains styles; a style contains selectors and rules; and a rule contains a property and a value. The following is the design pattern for a style:
SELECTORS { RULES }
The following is the design pattern for a rule:
PROPERTY:VALUE;
For example, p{margin:0;} is a style. p is the selector, which selects all [...]


Related posts:<ol><li><a href='http://csslearn.com/using-cascade-order' rel='bookmark' title='Permanent Link: Using Cascade Order'>Using Cascade Order</a> <small>CSS allows you to assign the same rule to the...</small></li>
<li><a href='http://csslearn.com/css-comments-looks' rel='bookmark' title='Permanent Link: CSS comments looks'>CSS comments looks</a> <small>CSS comments look like this: /* this is a comment...</small></li>
<li><a href='http://csslearn.com/types-of-css-selectors' rel='bookmark' title='Permanent Link: Types of CSS selectors'>Types of CSS selectors</a> <small>In the previous example, the most basic style of selector...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>CSS syntax is easy. A stylesheet contains styles; a style contains selectors and rules; and a rule contains a property and a value. The following is the design pattern for a style:<br />
<em><strong>SELECTORS { RULES }</strong></em><br />
The following is the design pattern for a rule:<br />
<em><strong>PROPERTY:VALUE;</strong></em><br />
For example, p{margin:0;} is a style. p is the selector, which selects all &lt;p&gt; elements in an HTML document. The curly bracket ({}) operators assign the rule, margin:0;, to the selector, p. The colon (:) operator assigns the value 0 to the property, margin. The semicolon (;) operator terminates the rule.</p>
<p>A style may have one or more selectors and one or more rules. For example, p.tip{margin:0; line-height:150%;} is a style. The curly bracket operators group the two rules, margin:0; and line-height:150%;, into a ruleset and assign it to the selector, p.tip, which selects all &lt;p&gt; elements in an HTML document.</p>
<h1>CSS Syntax Details</h1>
<p>The key points of CSS syntax are as follows:<br />
• Unicode UTF-8 should be used to encode CSS files—the same way you should encode HTML files.<br />
• CSS code should be lowercase. Selectors are case sensitive when referencing element names, classes, attributes, and IDs in XHTML.6 CSS properties and values are case insensitive. For simplicity and consistency, I use lowercase characters for all CSS code including elements, classes, and IDs.<br />
• Element names, classes, and IDs are restricted to letters, numbers, underscores (_), hyphens (-), and Unicode characters 161 and higher. The first character of an element, class, or ID must not be a number or a hyphen. A classname and ID must not contain punctuation other than the underscore and hyphen. For example, my_name2-1 is a valid name for a class or ID, but the following are invalid: 1, 1my_name, -my_name, my:name, my.name, and  my,name.<br />
• Multiple classes can be assigned to an element by separating each class name with a space, such as.<br />
• Constant values should not be placed in quotes. For example, color:black; is correct, but color:&#8221;black&#8221;; is not.<br />
• The backslash (\) can be used to embed characters in a context where they normally cannot occur; for example, \26B embeds &amp; in a string or identifier. Anywhere from two to eight hex codes can follow a backslash, or a character can follow a backslash.<br />
• A string may contain parentheses, commas, whitespace, single quotes (&#8216;), and double quotes (&#8220;) as long as they are escaped with a backslash, such as the following:<br />
<em><strong>&#8220;embedded left parentheses \( &#8221;<br />
&#8220;embedded right parentheses \) &#8221;<br />
&#8220;embedded comma \, &#8221;<br />
&#8220;embedded single quote \&#8217; &#8221;<br />
&#8220;embedded double quote \&#8221; &#8221;<br />
&#8220;embedded single quote &#8216; in a double-quoted string&#8221;<br />
&#8216;embedded double quote &#8221; in a single-quoted string&#8217;</strong></em></p>
<p>• A semicolon should terminate each CSS rule and @import statement.<em><strong> color:red; @import &#8220;mystylesheet.css&#8221;</strong></em>;<br />
• Rulesets are created by enclosing multiple rules in curly braces, such as<em><strong> { color:red; font-size:small; }</strong></em>.</p>
<p>• The right curly brace (}) immediately terminates a set of properties, unless it is embedded within a string, such as &#8220;}&#8221;.<br />
• A CSS comment starts with /* and ends with */, such as /* This is a CSS comment */. Comments cannot be nested. Thus, the first time a browser encounters */ in a stylesheet, it terminates the comment. If there are subsequent occurrences of /*, they are not interpreted as part of the comment. For example:<br />
<strong><em>/* This is an incorrect comment<br />
/* because it tries to nest<br />
/* several comments. */</em></strong><br />
<em><strong>STARTING HERE, THIS TEXT IS OUTSIDE OF ALL COMMENTS! */ */</strong></em></p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fcsslearn.com%2Fcss-syntax-syntax-details&amp;linkname=CSS%20Syntax%20%26%23038%3B%20Syntax%20Details"><img src="http://csslearn.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>

<p>Related posts:<ol><li><a href='http://csslearn.com/using-cascade-order' rel='bookmark' title='Permanent Link: Using Cascade Order'>Using Cascade Order</a> <small>CSS allows you to assign the same rule to the...</small></li>
<li><a href='http://csslearn.com/css-comments-looks' rel='bookmark' title='Permanent Link: CSS comments looks'>CSS comments looks</a> <small>CSS comments look like this: /* this is a comment...</small></li>
<li><a href='http://csslearn.com/types-of-css-selectors' rel='bookmark' title='Permanent Link: Types of CSS selectors'>Types of CSS selectors</a> <small>In the previous example, the most basic style of selector...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://csslearn.com/css-syntax-syntax-details/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Stylesheets</title>
		<link>http://csslearn.com/using-stylesheets</link>
		<comments>http://csslearn.com/using-stylesheets#comments</comments>
		<pubDate>Sun, 06 Dec 2009 18:23:32 +0000</pubDate>
		<dc:creator>kunal</dc:creator>
				<category><![CDATA[CSS Advanced]]></category>
		<category><![CDATA[CSS Basic]]></category>
		<category><![CDATA[CSS Examples]]></category>

		<guid isPermaLink="false">http://csslearn.com/?p=85</guid>
		<description><![CDATA[You can place styles in three locations: stylesheets, &#60;style&#62;, and style. A stylesheet is an independent file that you can attach to an HTML document using the &#60;link&#62; element or CSS’s @import statement. &#60;style&#62; is an HTML element that you can embed within the HTML document itself. style is an attribute that can be embedded [...]


Related posts:<ol><li><a href='http://csslearn.com/using-cascade-order' rel='bookmark' title='Permanent Link: Using Cascade Order'>Using Cascade Order</a> <small>CSS allows you to assign the same rule to the...</small></li>
<li><a href='http://csslearn.com/styling-for-print' rel='bookmark' title='Permanent Link: Styling for Print'>Styling for Print</a> <small>You can use a specific style sheet to style content...</small></li>
<li><a href='http://csslearn.com/adding-styles-to-a-web-page' rel='bookmark' title='Permanent Link: Adding styles to a web page'>Adding styles to a web page</a> <small>The most common (and useful) method of applying CSS rules...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>You can place styles in three locations: stylesheets, &lt;style&gt;, and style. A stylesheet is an independent file that you can attach to an HTML document using the &lt;link&gt; element or CSS’s @import statement. &lt;style&gt; is an HTML element that you can embed within the HTML document itself. style is an attribute that can be embedded within any HTML element. I recommend putting styles in stylesheets. This reduces noncontent in your HTML documents, and it puts all your styles in files that are easily managed.</p>
<p>I recommend naming stylesheets using single-word, lowercase names. This keeps stylesheet names simple and easy to remember, and works safely in all operating systems. I suggest you use a name that describes the scope and purpose of the stylesheet, such as site.css, page.css, handheld.css, print.css, and so forth. The standard extension for a<br />
stylesheet is .css. The standard Internet media type is text/css. I recommend using the location of a stylesheet to control its scope. If a stylesheet is for an entire web site, you could place it in the root directory of the web site. If a stylesheet applies only to a document, you could place it in the same directory as the document. To link a stylesheet to an HTML document, you can include a &lt;link&gt; element in the &lt;head&gt; section of HTML documents, and you can place the URI of the stylesheet within the href attribute of the &lt;link&gt; element. Listing 1-1 shows the stylesheet links that I use in each example in this book. See the Header Elements and Conditional Stylesheet design patterns in</p>
<p>Listing 1-1. Attaching Stylesheets<br />
&lt;link rel=&#8221;stylesheet&#8221; href=&#8221;site.css&#8221; media=&#8221;all&#8221; type=&#8221;text/css&#8221; /&gt;<br />
&lt;link rel=&#8221;stylesheet&#8221; href=&#8221;page.css&#8221; media=&#8221;all&#8221; type=&#8221;text/css&#8221; /&gt;<br />
&lt;link rel=&#8221;stylesheet&#8221; href=&#8221;print.css&#8221; media=&#8221;print&#8221; type=&#8221;text/css&#8221; /&gt;<br />
&lt;!&#8211;[if lte IE 6]&gt;<br />
&lt;link rel=&#8221;stylesheet&#8221; href=&#8221;ie6.css&#8221; media=&#8221;all&#8221; type=&#8221;text/css&#8221; /&gt;<br />
&lt;![endif]&#8211;&gt;<br />
For increased download performance, you may want to include page-specific styles in the &lt;style&gt; element instead of in a separate page-specific stylesheet. Since these styles are page specific, there is little disadvantage to putting these styles in the header of the page. On the other hand, I do strongly recommend against using the style attribute of HTML elements because this creates very hard-to-maintain code.</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fcsslearn.com%2Fusing-stylesheets&amp;linkname=Using%20Stylesheets"><img src="http://csslearn.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>

<p>Related posts:<ol><li><a href='http://csslearn.com/using-cascade-order' rel='bookmark' title='Permanent Link: Using Cascade Order'>Using Cascade Order</a> <small>CSS allows you to assign the same rule to the...</small></li>
<li><a href='http://csslearn.com/styling-for-print' rel='bookmark' title='Permanent Link: Styling for Print'>Styling for Print</a> <small>You can use a specific style sheet to style content...</small></li>
<li><a href='http://csslearn.com/adding-styles-to-a-web-page' rel='bookmark' title='Permanent Link: Adding styles to a web page'>Adding styles to a web page</a> <small>The most common (and useful) method of applying CSS rules...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://csslearn.com/using-stylesheets/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>List margins and padding</title>
		<link>http://csslearn.com/list-margins-and-padding</link>
		<comments>http://csslearn.com/list-margins-and-padding#comments</comments>
		<pubDate>Sun, 29 Nov 2009 17:12:10 +0000</pubDate>
		<dc:creator>kunal</dc:creator>
				<category><![CDATA[CSS Advanced]]></category>
		<category><![CDATA[CSS Basic]]></category>

		<guid isPermaLink="false">http://csslearn.com/?p=82</guid>
		<description><![CDATA[Browsers don’t seem to be able to agree on how much padding and margin to place around lists by default, and also how margin and padding settings affect lists in general. This can be frustrating when developing websites that rely on lists and pixel-perfect element placement. By creating a list and using CSS to apply [...]


Related posts:<ol><li><a href='http://csslearn.com/content-margins-and-padding-in-css' rel='bookmark' title='Permanent Link: Content margins and padding in CSS'>Content margins and padding in CSS</a> <small>Page margins and padding are easy to define using CSS....</small></li>
<li><a href='http://csslearn.com/working-with-listsunordered-listsordered-listsdefinition-lists-nesting-lists' rel='bookmark' title='Permanent Link: Working with lists,Unordered lists,Ordered lists,Definition lists &#038; Nesting lists'>Working with lists,Unordered lists,Ordered lists,Definition lists &#038; Nesting lists</a> <small>This post concludes with the last of the major type...</small></li>
<li><a href='http://csslearn.com/working-with-css-shorthand-for-boxes' rel='bookmark' title='Permanent Link: Working with CSS shorthand for boxes'>Working with CSS shorthand for boxes</a> <small>This is something that is useful to get to grips...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Browsers don’t seem to be able to agree on how much padding and margin to place around lists by default, and also how margin and padding settings affect lists in general. This can be frustrating when developing websites that rely on lists and pixel-perfect element placement. By creating a list and using CSS to apply a background color to the list<br />
and a different color to list items, and then removing the page’s padding and margins, you can observe how each browser creates lists and indents the bullet points and content. In Gecko browsers (e.g., Mozilla Firefox), Opera, and Safari, the list background color is displayed behind the bullet points, which suggests that those browsers place bullet points within the list’s left-hand padding (because backgrounds extend into an element’s padding). Internet Explorer shows no background color there, suggesting it places bullet points within the list’s left-hand margin. This is confirmed if you set the margin property to 0 for a ul selector in CSS. The list is unaffected in all browsers but Internet Explorer, in which the bullets abut the left edge of the web browser window. Conversely, setting padding to 0 makes the same thing happen in Gecko browsers, Safari, and Opera. To get all browsers on a level playing field, you must remove margins and padding, which, as mentioned previously in this book, is done in CSS by way of the universal selector:<br />
<strong><em><br />
* {<br />
margin: 0;<br />
padding: 0;<br />
}</em></strong></p>
<p>With this in place, all browsers render lists in the same way, and you can set specific values as appropriate. For example, bring back the bullet points (which may be at least partially hidden if margins and padding are both zeroed) by setting either the margin-left or padding-left value to 1.5em (i.e., set margin: 0 0 0 1.5em or padding: 0 0 0 1.5em).<br />
The difference is that if you set padding-left, any background applied to the list will appear behind the bullet points, but if you set margin-left, it won’t. Note that 1.5em is a big enough value to enable the bullet points to display (in fact, lower values are usually sufficient, too—although take care not to set values too low, or the bullets will be clipped); setting a higher value places more space to the left of the bullet points.</p>
<p>Inline lists for navigation</p>
<p>Although most people think of lists as being vertically aligned, you can also display list items inline. This is particularly useful when creating navigation bars, as you’ll see. To set a list to display inline, you simply add display: inline; to the li<br />
selector. Adding list-style-type: none; to the ul selector ensures that the list sits snug to the left of its container (omitting this tends to indent the list items). Adding a margin-right value to li also ensures that the list items don’t sit right next to each other. Here’s an example:<br />
<em><strong>ul {<br />
list-style-type: none;<br />
}<br />
li {<br />
display: inline;<br />
margin-right: 10px;<br />
}</strong></em></p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fcsslearn.com%2Flist-margins-and-padding&amp;linkname=List%20margins%20and%20padding"><img src="http://csslearn.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>

<p>Related posts:<ol><li><a href='http://csslearn.com/content-margins-and-padding-in-css' rel='bookmark' title='Permanent Link: Content margins and padding in CSS'>Content margins and padding in CSS</a> <small>Page margins and padding are easy to define using CSS....</small></li>
<li><a href='http://csslearn.com/working-with-listsunordered-listsordered-listsdefinition-lists-nesting-lists' rel='bookmark' title='Permanent Link: Working with lists,Unordered lists,Ordered lists,Definition lists &#038; Nesting lists'>Working with lists,Unordered lists,Ordered lists,Definition lists &#038; Nesting lists</a> <small>This post concludes with the last of the major type...</small></li>
<li><a href='http://csslearn.com/working-with-css-shorthand-for-boxes' rel='bookmark' title='Permanent Link: Working with CSS shorthand for boxes'>Working with CSS shorthand for boxes</a> <small>This is something that is useful to get to grips...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://csslearn.com/list-margins-and-padding/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Working with lists,Unordered lists,Ordered lists,Definition lists &amp; Nesting lists</title>
		<link>http://csslearn.com/working-with-listsunordered-listsordered-listsdefinition-lists-nesting-lists</link>
		<comments>http://csslearn.com/working-with-listsunordered-listsordered-listsdefinition-lists-nesting-lists#comments</comments>
		<pubDate>Sun, 29 Nov 2009 17:03:10 +0000</pubDate>
		<dc:creator>kunal</dc:creator>
				<category><![CDATA[CSS Basic]]></category>

		<guid isPermaLink="false">http://csslearn.com/?p=79</guid>
		<description><![CDATA[This post concludes with the last of the major type elements: the list. We’ll first look at the different types of lists—unordered, ordered, and definition—and also see how to nest them. Then we’ll move on to cover how to style lists in CSS, list margins and padding, and inline lists.
Unordered lists
The unordered list, commonly referred [...]


Related posts:<ol><li><a href='http://csslearn.com/list-margins-and-padding' rel='bookmark' title='Permanent Link: List margins and padding'>List margins and padding</a> <small>Browsers don’t seem to be able to agree on how...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>This post concludes with the last of the major type elements: the list. We’ll first look at the different types of lists—unordered, ordered, and definition—and also see how to nest them. Then we’ll move on to cover how to style lists in CSS, list margins and padding, and inline lists.</p>
<h2>Unordered lists</h2>
<p>The unordered list, commonly referred to as a bullet point list, is the most frequently seen type of list online. The list is composed of an unordered list element (&lt;ul&gt;&lt;/ul&gt;) and any number of list items within, each of which looks like this (prior to content being added): &lt;li&gt;&lt;/li&gt;. An example of an unordered list follows, and the resulting browser display is<br />
shown to the right. As you can see, browsers typically render a single-level unordered list with solid black bullet points.</p>
<p><em><strong>&lt;ul&gt;<br />
&lt;li&gt;List item one&lt;/li&gt;<br />
&lt;li&gt;List item two&lt;/li&gt;<br />
&lt;li&gt;List item &#8216;n&#8217;&lt;/li&gt;<br />
&lt;/ul&gt;</strong></em></p>
<p><em><strong>Unlike HTML, XHTML lists require end tags on all list elements. In HTML, the &lt;/li&gt; end tag was optional.</strong></em></p>
<h2>Ordered lists</h2>
<p>On occasion, list items must be stated in order, whereupon an ordered list is used. It works in the same way as an unordered list, the only difference being the containing element, which is &lt;ol&gt;&lt;/ol&gt;.<br />
<em><strong>&lt;ol&gt;<br />
&lt;li&gt;List item one&lt;/li&gt;<br />
&lt;li&gt;List item two&lt;/li&gt;<br />
&lt;li&gt;List item &#8216;n&#8217;&lt;/li&gt;<br />
&lt;/ol&gt;</strong></em></p>
<p><strong><em>Web browsers automatically insert the item numbers when you use ordered lists. The only way of controlling numbering directly is via the start attribute, whose value dictates the first number of the ordered list. Note, though, that this attribute is deprecated— use it and your web page will not validate as XHTML Strict.</em></strong></p>
<h2>Definition lists</h2>
<p>A definition list isn’t a straightforward list of items. Instead, it’s a list of terms and explanations. This type of list isn’t common online, but it has its uses. The list itself is enclosed in the definition list element (&lt;dl&gt;&lt;/dl&gt;), and within the element are placed terms and definitions, marked up with &lt;dt&gt;&lt;/dt&gt; and &lt;dd&gt;&lt;/dd&gt;, respectively. Generally speaking, browsers display the definition with an indented left-hand margin, as in the following example.</p>
<p><strong><em>&lt;dl&gt;<br />
&lt;dt&gt;Cat&lt;/dt&gt;<br />
&lt;dd&gt;Four-legged, hairy animal, with an inflated sense of self-importance&lt;/dd&gt;<br />
&lt;dt&gt;Dog&lt;/dt&gt;<br />
&lt;dd&gt;Four-legged, hairy animal, often with å an inferiority complex&lt;/dd&gt;<br />
&lt;/dl&gt;</em></strong></p>
<h2>Nesting lists</h2>
<p>Lists can be nested, but designers often do so incorrectly, screwing up their layouts and rendering web pages invalid. The most common mistake is placing the nested list outside any list items, as shown in the following incorrect example:<br />
<strong><em>&lt;ul&gt;<br />
&lt;li&gt;List item one&lt;/li&gt;<br />
&lt;ul&gt;<br />
&lt;li&gt;Nested list item one&lt;/li&gt;<br />
&lt;li&gt;Nested list item two&lt;/li&gt;<br />
&lt;/ul&gt;<br />
&lt;li&gt;List item two&lt;/li&gt;<br />
&lt;li&gt;List item &#8216;n&#8217;&lt;/li&gt;<br />
&lt;/ul&gt;</em></strong></p>
<p>Nested lists must be placed inside a list item, after the relevant item that leads into the nested list. Here’s an example:<br />
<em><strong>&lt;ul&gt;<br />
&lt;li&gt;List item one<br />
&lt;ul&gt;<br />
&lt;li&gt;Nested list item one&lt;/li&gt;<br />
&lt;li&gt;Nested list item two&lt;/li&gt;<br />
&lt;/ul&gt;<br />
&lt;/li&gt;<br />
&lt;li&gt;List item two&lt;/li&gt;<br />
&lt;li&gt;List item &#8216;n&#8217;&lt;/li&gt;<br />
&lt;/ul&gt;</strong></em></p>
<p>Always ensure that the list element that contains the nested list is closed with an end tag. Not doing so is another common mistake, and although it’s not likely to cause as many problems as the incorrect positioning of the list, it can still affect your layout.</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fcsslearn.com%2Fworking-with-listsunordered-listsordered-listsdefinition-lists-nesting-lists&amp;linkname=Working%20with%20lists%2CUnordered%20lists%2COrdered%20lists%2CDefinition%20lists%20%26%23038%3B%20Nesting%20lists"><img src="http://csslearn.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>

<p>Related posts:<ol><li><a href='http://csslearn.com/list-margins-and-padding' rel='bookmark' title='Permanent Link: List margins and padding'>List margins and padding</a> <small>Browsers don’t seem to be able to agree on how...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://csslearn.com/working-with-listsunordered-listsordered-listsdefinition-lists-nesting-lists/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Styling semantic markup</title>
		<link>http://csslearn.com/styling-semantic-markup</link>
		<comments>http://csslearn.com/styling-semantic-markup#comments</comments>
		<pubDate>Fri, 27 Nov 2009 14:29:35 +0000</pubDate>
		<dc:creator>kunal</dc:creator>
				<category><![CDATA[CSS Basic]]></category>

		<guid isPermaLink="false">http://csslearn.com/?p=77</guid>
		<description><![CDATA[The exercises in this section will combine the elements discussed so far in this post, showing how to use the knowledge gained to style some semantic markup. Three different examples are on offer, showing how rapidly you can create great-looking text when working with CSS, and also how you can easily restyle a page of [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>The exercises in this section will combine the elements discussed so far in this post, showing how to use the knowledge gained to style some semantic markup. Three different examples are on offer, showing how rapidly you can create great-looking text when working with CSS, and also how you can easily restyle a page of text without touching the markup. The markup that you’ll use is as per that in the next code block; and the default web page, without any CSS applied, is shown to its right.</p>
<p>&lt;div id=&#8221;wrapper&#8221;&gt;<br />
&lt;h1&gt;Article heading&lt;/h1&gt;<br />
&lt;p&gt;Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed å aliquet elementum erat. Integer å diam mi, venenatis non, cursus å a, hendrerit at, mi. Morbi risus å mi, tincidunt ornare, tempus å ut, eleifend nec, risus.&lt;/p&gt;<br />
&lt;p&gt;Quisque faucibus lorem eget sapien. å In urna sem, vehicula ut, å mattis et, venenatis at, velit. å Ut sodales lacus sed eros. å Pellentesque tristique senectus et å netus et malesuada fames å ac turpis egestas.&lt;/p&gt;<br />
&lt;h2&gt;Curabitur sit amet risus&lt;/h2&gt;<br />
&lt;p&gt;Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed å aliquet elementum erat. Integer å diam mi,  vene natis non, cursus a, hendrerit at, mi. Morbi risus mi, tincidunt ornare, tempus å ut, eleifend nec, risus.&lt;/p&gt;<br />
&lt;p&gt;Quisque faucibus lorem eget sapien. In urna sem, vehicula ut, å mattis et, venenatis at, velit. Ut sodales lacus sed eros. å Pellentesque tristique senectus et netus et malesuada fames å ac turpis egestas.&lt;/p&gt;<br />
&lt;h3&gt;Praesent rutrum&lt;/h3&gt;<br />
&lt;p&gt;Nam scelerisque dignissim quam. Ut bibendum enim in orci. Vivamus å ligula nunc, dictum a, tincidunt in, dignissim ac, odio.&lt;/p&gt;<br />
&lt;h3&gt;Habitant morbid&lt;/h3&gt;<br />
&lt;p&gt;Nam scelerisque dignissim quam. Ut bibendum enim in orci. Vivamus å ligula nunc, dictum a, tincidunt in, dignissim ac, odio.&lt;/p&gt;<br />
&lt;/div&gt;</p>
<p>The code block is simple. The text has three levels of headings, with paragraphs between them. Everything’s enclosed in a div element, which will be styled to restrict the width of its content. This makes it simpler to see how the leading—defined via line-height—is working out. If you were surfing at full-screen on a large monitor, the paragraphs might<br />
only be shown on a single line.</p>
<p>The default CSS document for these exercises has some rules common to all three examples. These are shown in the following code block:</p>
<p>* { margin: 0; padding: 0; }<br />
html { font-size: 100%; }<br />
body {padding: 20px; font-size: 62.5%;}<br />
#wrapper {margin: 0 auto;width: 400px;}</p>
<p>The first rule, *, removes margins and padding from all elements, as discussed previously. The html and body rules set the default size of the text on the web page to 62.5%, as explained in the “Setting text using percentages and ems” section earlier in this chapter. Finally, the #wrapper rule defines a width for the wrapper div, and therefore for its content.</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fcsslearn.com%2Fstyling-semantic-markup&amp;linkname=Styling%20semantic%20markup"><img src="http://csslearn.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>

<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://csslearn.com/styling-semantic-markup/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating alternatives with classes and spans</title>
		<link>http://csslearn.com/creating-alternatives-with-classes-and-spans</link>
		<comments>http://csslearn.com/creating-alternatives-with-classes-and-spans#comments</comments>
		<pubDate>Fri, 27 Nov 2009 14:19:53 +0000</pubDate>
		<dc:creator>kunal</dc:creator>
				<category><![CDATA[CSS Basic]]></category>

		<guid isPermaLink="false">http://csslearn.com/?p=75</guid>
		<description><![CDATA[It’s common in web design to define alternatives to the rules set for tag selectors (h1, h2, p, etc.). This tends to happen most often in one of two situations. The first is when creating alternate styles for a portion of a web page (as in print, it’s often beneficial to use different text for [...]


Related posts:<ol><li><a href='http://csslearn.com/types-of-css-selectors' rel='bookmark' title='Permanent Link: Types of CSS selectors'>Types of CSS selectors</a> <small>In the previous example, the most basic style of selector...</small></li>
<li><a href='http://csslearn.com/css-shorthand-for-font-properties' rel='bookmark' title='Permanent Link: CSS shorthand for font properties'>CSS shorthand for font properties</a> <small>The CSS properties discussed so far can be written in...</small></li>
<li><a href='http://csslearn.com/setting-a-default-font-and-font-color-using-css' rel='bookmark' title='Permanent Link: Setting a default font and font color using CSS'>Setting a default font and font color using CSS</a> <small>As mentioned earlier, the body start tag was historically used...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>It’s common in web design to define alternatives to the rules set for tag selectors (h1, h2, p, etc.). This tends to happen most often in one of two situations. The first is when creating alternate styles for a portion of a web page (as in print, it’s often beneficial to use different text for sidebars and boxouts—standalone boxes on a magazine page, either housing supplementary information to the main article, or an entirely independent piece that needs to be visually distinct from other content on the page—and sidebars to ensure that each area of content is easy to distinguish from another). In this situation, it’s sensible to define a default rule for each element using an element selector, and then create an override for the portion of the page that requires different text by using a contextual selector.</p>
<p>For example, imagine a typical web page that has a sidebar that’s marked up as a div with an id value of sidebar. You might use a different paragraph font in the sidebar, to differentiate the text, like so:</p>
<p><em><strong>p { font: 1.2em/1.5 Verdana, Arial, sans-serif; margin-bottom: 1em; }<br />
#sidebar p { font: 1.2em/1.5 Arial, sans-serif; }<br />
</strong></em><br />
The other occasion where alternatives are required is when creating one-off styles to override an existing style. In such cases, you can define a class in the CSS and then use a class attribute to apply it to an element. Should you only want a portion of some text to take on the style, you can surround the selection with a span element and apply the class to that<br />
instead.</p>
<p>For example, if you wanted to create some “warning” text, you could use the following<br />
CSS:</p>
<p><em><strong>.warningText { color: #ff0000;font-size: 120%; }</strong></em></p>
<p>This can then be applied as follows:<br />
<em><strong>&lt;p&gt;This paragraph takes on the styles defined in å the warningText class&lt;/p&gt;<br />
&lt;p&gt;Only &lt;span&gt;this portion&lt;/span&gt; of this å paragraph takes on the warningText class styles.&lt;/p&gt;<br />
</strong></em><br />
Avoid overusing span elements, though. Text works best when it’s consistent across the page.</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fcsslearn.com%2Fcreating-alternatives-with-classes-and-spans&amp;linkname=Creating%20alternatives%20with%20classes%20and%20spans"><img src="http://csslearn.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>

<p>Related posts:<ol><li><a href='http://csslearn.com/types-of-css-selectors' rel='bookmark' title='Permanent Link: Types of CSS selectors'>Types of CSS selectors</a> <small>In the previous example, the most basic style of selector...</small></li>
<li><a href='http://csslearn.com/css-shorthand-for-font-properties' rel='bookmark' title='Permanent Link: CSS shorthand for font properties'>CSS shorthand for font properties</a> <small>The CSS properties discussed so far can be written in...</small></li>
<li><a href='http://csslearn.com/setting-a-default-font-and-font-color-using-css' rel='bookmark' title='Permanent Link: Setting a default font and font color using CSS'>Setting a default font and font color using CSS</a> <small>As mentioned earlier, the body start tag was historically used...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://csslearn.com/creating-alternatives-with-classes-and-spans/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
