<?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>Blogging Tips &#187; CSS</title>
	<atom:link href="http://www.bloggingtips.com/category/design-coding/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bloggingtips.com</link>
	<description>Blogging Guides, News, Tips, Resources</description>
	<lastBuildDate>Fri, 19 Mar 2010 18:00:48 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Creating a Drop Down Menu</title>
		<link>http://www.bloggingtips.com/2009/04/09/creating-a-drop-down-menu/</link>
		<comments>http://www.bloggingtips.com/2009/04/09/creating-a-drop-down-menu/#comments</comments>
		<pubDate>Thu, 09 Apr 2009 19:00:47 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://www.bloggingtips.com/?p=6382</guid>
		<description><![CDATA[Horizontal navigation is quite popular however it becomes restrictive once you&#8217;ve got too many pages to list. Once you reach this point then you either need to convert to using a vertical navigation, or start using drop down menus.
Drop downs used to rely on JavaScript however all modern browsers can now manage drop down menus [...]<p><a href="http://www.bloggingtips.com/2009/04/09/creating-a-drop-down-menu/">Creating a Drop Down Menu</a><br /><br />
<a href="http://www.bloggingtips.com/books/"><img src="http://www.bloggingtips.com/ebooks/images/blogging-tips-books.png" alt="Blogging Tips Books"></a><br />
A selection of e-books to help you improve as a blogger.
Find out more at <a href="http://www.bloggingtips.com/books">www.bloggingtips.com/books/</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Horizontal navigation is quite popular however it becomes restrictive once you&#8217;ve got too many pages to list. Once you reach this point then you either need to convert to using a vertical navigation, or start using drop down menus.</p>
<p>Drop downs used to rely on JavaScript however all modern browsers can now manage drop down menus with just CSS (IE7+, Firefox, Opera, Safari; note, JavaScript is still required for IE6 and below).</p>
<h3>The HTML Navigation</h3>
<p>First we need to set up the html correctly. To do this we need to use nested lists. A list is usually written as</p>
<pre class="brush: html;">&lt;ul&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Page 1&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Page 2&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Page 3&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Page 4&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</pre>
<p>We need to then create a list for each drop down and nest it into the list item for the parent link ie.</p>
<pre class="brush: html;">&lt;ul id=&quot;menu&quot;&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Page 1&lt;/a&gt;
        &lt;ul&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Subpage 1&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Subpage 2&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Subpage 3&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Page 2&lt;/a&gt;
        &lt;ul&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Subpage 1&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Subpage 2&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Subpage 3&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Page 3&lt;/a&gt;
        &lt;ul&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Subpage 1&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Subpage 2&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Subpage 3&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Page 4&lt;/a&gt;
        &lt;ul&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Subpage 1&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Subpage 2&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Subpage 3&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
    &lt;/li&gt;
&lt;/ul&gt;</pre>
<p>As you can see, to nest the list the parent item and the sub menu is all wrapped within the list item tags (note, if you use WordPress then your page navigation is automatically created like this by default).</p>
<h3>The CSS Code</h3>
<p>With the CSS code, first we need to turn our list into a horizontal list. I&#8217;ve covered this previously on <a href="http://www.bloggingtips.com/2009/01/01/css-basics-list-properties-ii/">List Properties</a>. So we need to add in the code required to make a horizontal menu and we&#8217;ll make it neat at the same time, which is</p>
<pre class="brush: css;">#menu {
    list-style: none;
    margin: 0;
    padding: 0;
}
#menu li {
    float: left;
    width: 75px;
    margin: 0 1px;
    background: #900;
    text-align: center;
    border: 1px solid #009;
}
#menu a {
    color: #fff;
    display: block;
    text-decoration: none;
    padding: 2px 0 3px;
    width: 75px;
}
#menu a:hover {
    background: #000;
}</pre>
<p>Now we need to hide the sub menu out of sight until it&#8217;s required. To do this we use absolute positioning and &#8216;push&#8217; it off the page eg.</p>
<pre class="brush: css;">#menu li ul {
	position: absolute;
	width: 75px;
	left: -5000px;
}</pre>
<p>This will hide the menu visually however a screenreader will still read the menu as normal, as will a search engine spider.</p>
<p>Now all we need to do is to set the menu to display when the user hovers over the parent menu. To do with we use the :hover pseudo class ie.</p>
<pre class="brush: css;">#menu li:hover ul {
	left: auto;
}</pre>
<p>By using the property value of auto, we bring the list back into view, and make it appear below the parent link as it should.</p>
<p>Finally we need to tidy up the sub menu by removing the margins, padding and list style from it by targeting the sub menu in the first ruleset above. We also need to remove the left and right margin from the sub menu list items, as it will inherit the 1px left/right margin from our ruleset above for #nav li. Also, because we&#8217;ve used a border on the list items, the sub menu list has shifted over a pixel to the right, so we can fix this by using a negative margin to move it back to the left and line it up correctly ie.</p>
<pre class="brush: css;">#menu li li {
	margin: 0 0 0 -1px;
}</pre>
<p>This gives us the final menu code and working example &#8211; <a href='http://www.bloggingtips.com/wp-content/uploads/2009/04/dropdowns.html'>Dropdown Menu Example</a>.</p>
<p>This code and the menu is based on the <a href="http://www.htmldog.com/articles/suckerfish/dropdowns/">Son of Suckerfish Dropdowns</a>, where you can also see how to create multiple dropdowns and also how to add in the JavaScript code to have the menu working for IE6 and below as well.</p>
<hr>Copyright &copy; 2010 <strong><a href="http://www.bloggingtips.com">Blogging Tips</a></strong>. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. Please <a href=http://www.bloggingtips.com/contact/>contact us</a> so we can take legal action immediately.<p><a href="http://www.bloggingtips.com/2009/04/09/creating-a-drop-down-menu/">Creating a Drop Down Menu</a><br /><br />
<a href="http://www.bloggingtips.com/books/"><img src="http://www.bloggingtips.com/ebooks/images/blogging-tips-books.png" alt="Blogging Tips Books"></a><br />
A selection of e-books to help you improve as a blogger.
Find out more at <a href="http://www.bloggingtips.com/books">www.bloggingtips.com/books/</a></p>
<img src="http://www.bloggingtips.com/?ak_action=api_record_view&id=6382&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.bloggingtips.com/2009/04/09/creating-a-drop-down-menu/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Explaining CSS Selectors Part III</title>
		<link>http://www.bloggingtips.com/2009/03/26/explaining-css-selectors-part-iii/</link>
		<comments>http://www.bloggingtips.com/2009/03/26/explaining-css-selectors-part-iii/#comments</comments>
		<pubDate>Thu, 26 Mar 2009 20:00:09 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://www.bloggingtips.com/?p=6013</guid>
		<description><![CDATA[This is the final part in this 3 part series (see Part I and Part II), and we&#8217;re on to Pseudo-element selectors.
:first-line
The :first-line pseudo-element allows you to target the first line of a given target, which must be either a block level element, inline-block, table cell or caption. So, for example, if you wanted to [...]<p><a href="http://www.bloggingtips.com/2009/03/26/explaining-css-selectors-part-iii/">Explaining CSS Selectors Part III</a><br /><br />
<a href="http://www.bloggingtips.com/books/"><img src="http://www.bloggingtips.com/ebooks/images/blogging-tips-books.png" alt="Blogging Tips Books"></a><br />
A selection of e-books to help you improve as a blogger.
Find out more at <a href="http://www.bloggingtips.com/books">www.bloggingtips.com/books/</a></p>
]]></description>
			<content:encoded><![CDATA[<p>This is the final part in this 3 part series (see <a href="">Part I</a> and <a href="http://www.bloggingtips.com/2009/03/19/explaining-css-selectors-ii/">Part II</a>), and we&#8217;re on to Pseudo-element selectors.</p>
<h3>:first-line</h3>
<p>The :first-line pseudo-element allows you to target the first line of a given target, which must be either a block level element, inline-block, table cell or caption. So, for example, if you wanted to make the first line of a paragraph red then you could use</p>
<pre class="brush: css;">p:first-line { color: red }</pre>
<p>The properties available to use with this selector are similar to that of the inline elements, which you can associate with text formatting eg. font, text-transform, line-height etc.</p>
<h3>:first-letter</h3>
<p>This selector allows you to target the first letter of the given tag and is commonly used to create a large initial letter or a drop cap. The properties available are that of the text formatting properties, along with border, padding and margin.</p>
<p>To make a larger initial letter then you could just apply a font size and weight to it eg.</p>
<pre class="brush: css;">p:first-letter {
    font-size: 2em;
    font-weight: bold;
}</pre>
<p>To create a drop cap we would need to float the letter as well eg.</p>
<pre class="brush: css;">p:first-letter {
    font-size: 2em;
    font-weight: bold;
    float: left;
}</pre>
<h3>:before and :after</h3>
<p>Finally, the :before and :after selectors allow you to add content to your site by targeting specific elements. They&#8217;re used in conjunction with the content property. For example, if you wanted to insert a word at the start of the paragraph with an id of dynamic you could use</p>
<pre class="brush: css;">p#dynamic:before { content: &quot;Chapter 1: &quot; }</pre>
<p>Which would then take a piece of content such as</p>
<pre class="brush: html;">&lt;p&gt;&quot;Hello&quot;, she said, &quot;how are you today?&quot;&lt;/p&gt;</pre>
<p>to become</p>
<pre class="brush: html;">&lt;p&gt;Chapter 1: &quot;Hello&quot;, she said, &quot;how are you today?&quot;&lt;/p&gt;</pre>
<p>The content property can accept a standard string, it can also accept the values of</p>
<dl>
<dt>open-quote</dt>
<dd>Adds an opening quote eg. for at the start of paragraphs within a  blockquote.</dd>
<dt>close-quote</dt>
<dd>Adds a closing quote eg. for at the end of the final paragraph of a blockquote.</dd>
<dt>no-open-quote</dt>
<dd>Doesn&#8217;t add a quote mark at the start but does increment the quote level when a quote hierarchy has been defined (see below)</dd>
<dt>no-close-quote</dt>
<dd>Doesn&#8217;t add a quote mark at the end but does decrement the quote level when a quote hierarchy has been defined (see below)</dd>
<dt>An attribute value</dt>
<dd>This will get the value of a specific attribute</dd>
</dl>
<p>In order to use open-quote and close-quote the value for the quote marks needs to be defined with the &#8216;quotes&#8217; property, for example:</p>
<pre class="brush: css;">
q { quotes: '&quot;' '&quot;' &quot;'&quot; &quot;'&quot;; }
q:before { content: open-quote; }
q:after  { content: close-quote; }
</pre>
<p>The above CSS would set the opening and closing quote marks to be a double quotes with nested quotes set to use single opening and closing quote marks.</p>
<p>A working example of how to make use of the attribute value is to use the cite attribute for a blockquote tag. Then we can use the :after selector and content property to grab the value within this cite attribute and output it after the blockquote eg. (CSS code courtesey of <a href="http://www.ap4a.co.uk">David Anderson</a>)</p>
<pre class="brush: css;">blockquote[cite]:after {
	display : block;
	margin : 0 0 5px;
	padding : 0 0 2px 0;
	font-weight : bold;
	font-size : 90%;
	content : &quot;[source: &quot;&quot; &quot; attr(cite)&quot;]&quot;;
}</pre>
<p>There is much more that the content property can do such as counters and improved list numbering, however these would require their own individual posts which I will come around to.</p>
<p>Hopefully this has opened your eyes to the amount of additional functionality and targeting that CSS can give. Some of these options are not very well supported in IE7, hopefully now with IE8 out, we can start to use more of the functionality that is available to us, and start to move away from the total lack of support in IE6 for anything more than the standard CSS selectors!</p>
<hr>Copyright &copy; 2010 <strong><a href="http://www.bloggingtips.com">Blogging Tips</a></strong>. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. Please <a href=http://www.bloggingtips.com/contact/>contact us</a> so we can take legal action immediately.<p><a href="http://www.bloggingtips.com/2009/03/26/explaining-css-selectors-part-iii/">Explaining CSS Selectors Part III</a><br /><br />
<a href="http://www.bloggingtips.com/books/"><img src="http://www.bloggingtips.com/ebooks/images/blogging-tips-books.png" alt="Blogging Tips Books"></a><br />
A selection of e-books to help you improve as a blogger.
Find out more at <a href="http://www.bloggingtips.com/books">www.bloggingtips.com/books/</a></p>
<img src="http://www.bloggingtips.com/?ak_action=api_record_view&id=6013&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.bloggingtips.com/2009/03/26/explaining-css-selectors-part-iii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Explaining CSS Selectors Part II</title>
		<link>http://www.bloggingtips.com/2009/03/19/explaining-css-selectors-ii/</link>
		<comments>http://www.bloggingtips.com/2009/03/19/explaining-css-selectors-ii/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 20:00:51 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://www.bloggingtips.com/?p=5922</guid>
		<description><![CDATA[See last weeks post for part one of Explaining CSS Selectors.
Attribute Selectors
Attribute selectors allow you to target a group of items on a page by matching a particular attribute. This opens up a whole new method of selecting your targets. Unfortunately attribute selectors are not supported in IE6 (which is why they&#8217;re not very commonly [...]<p><a href="http://www.bloggingtips.com/2009/03/19/explaining-css-selectors-ii/">Explaining CSS Selectors Part II</a><br /><br />
<a href="http://www.bloggingtips.com/books/"><img src="http://www.bloggingtips.com/ebooks/images/blogging-tips-books.png" alt="Blogging Tips Books"></a><br />
A selection of e-books to help you improve as a blogger.
Find out more at <a href="http://www.bloggingtips.com/books">www.bloggingtips.com/books/</a></p>
]]></description>
			<content:encoded><![CDATA[<p>See last weeks post for part one of <a href="http://www.bloggingtips.com/2009/03/12/explaining-css-selectors-i/">Explaining CSS Selectors</a>.</p>
<h3>Attribute Selectors</h3>
<p>Attribute selectors allow you to target a group of items on a page by matching a particular attribute. This opens up a whole new method of selecting your targets. Unfortunately attribute selectors are not supported in IE6 (which is why they&#8217;re not very commonly used), and IE7&#8217;s support is a bit buggy at times, however with IE8 out today, hopefully support for these selectors will be greatly increased and we can finally get away from being held back by supporting IE6 users.</p>
<p>Attribute selectors can be used in a number of ways. You start with either a HTML selector or the universal selector (*) followed by the attribute selector within square brackets ie.</p>
<pre class="brush: css;">img[alt] { border: 2px solid red; }
img[rel=&quot;external&quot;] { border: 2px solid blue; }
img[alt~=&quot;photo&quot;] { border: 2px solid green; }
p[lang|=&quot;en&quot;] { color: red; }</pre>
<p>Going through the methods above:</p>
<ol>
<li>This will give any image on a page a red border if the image has an alt attribute</li>
<li>This will give any image with an attribute of rel that has the exact value of external, a blue border</li>
<li>This will give any image with an alt attribute whose value contains the word photo somewhere in it, a green border</li>
<li>This will set any paragraph of text to be red, if it has been assigned a language attribute whose value starts with &#8216;en&#8217; followed by a hyphen and then usually further information eg. en-US or en-GB</li>
</ol>
<h3>Pseudo-classes</h3>
<p>Pseudo-classes allow you to target even more specific elements on the page. We&#8217;ve seen some of these before however I&#8217;ll cover them all below.</p>
<h4>:first-child</h4>
<p>The first-child pseudo-class matches an element that is the first child element of another element. For example, to target the first list item in a list you could use</p>
<pre class="brush: css;">ul li:first-child { margin-left: 20px }</pre>
<h4>:link</h4>
<p>Allows you to specify the properties for an unvisited anchor link eg.</p>
<pre class="brush: css;">a:link { colour: blue; }</pre>
<h4>:visited</h4>
<p>Allows you to specify the properties for a visited anchor link.</p>
<h4>Dynamic pseudo-classes</h4>
<p>There are 3 dynamic pseudo-classes that are usually activated by a user on the page. The 3 selectors are</p>
<dl>
<dt>:hover</dt>
<dd>Activates when the user hovers their pointer over an element on the page eg. a link</dd>
<dt>:focus</dt>
<dd>Activates when the element has focus</dd>
<dt>:active</dt>
<dd>Applies when the element has been activated</dd>
</dl>
<p>Next week I&#8217;ll cover the last of the selectors, the pseudo-elements, and also give some every day examples of using these more advanced selectors.</p>
<hr>Copyright &copy; 2010 <strong><a href="http://www.bloggingtips.com">Blogging Tips</a></strong>. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. Please <a href=http://www.bloggingtips.com/contact/>contact us</a> so we can take legal action immediately.<p><a href="http://www.bloggingtips.com/2009/03/19/explaining-css-selectors-ii/">Explaining CSS Selectors Part II</a><br /><br />
<a href="http://www.bloggingtips.com/books/"><img src="http://www.bloggingtips.com/ebooks/images/blogging-tips-books.png" alt="Blogging Tips Books"></a><br />
A selection of e-books to help you improve as a blogger.
Find out more at <a href="http://www.bloggingtips.com/books">www.bloggingtips.com/books/</a></p>
<img src="http://www.bloggingtips.com/?ak_action=api_record_view&id=5922&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.bloggingtips.com/2009/03/19/explaining-css-selectors-ii/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Explaining CSS Selectors Part I</title>
		<link>http://www.bloggingtips.com/2009/03/12/explaining-css-selectors-i/</link>
		<comments>http://www.bloggingtips.com/2009/03/12/explaining-css-selectors-i/#comments</comments>
		<pubDate>Thu, 12 Mar 2009 20:00:36 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://www.bloggingtips.com/?p=5849</guid>
		<description><![CDATA[Now that we&#8217;ve covered a lot of information on HTML and some brief information on CSS, it&#8217;s now time to explore the power of CSS even more.
Selectors
Selectors allow you to target specific tags, ids, classes, attributes and more, on a page, ie. target a specific item or a group of items. We&#8217;ve seen and used [...]<p><a href="http://www.bloggingtips.com/2009/03/12/explaining-css-selectors-i/">Explaining CSS Selectors Part I</a><br /><br />
<a href="http://www.bloggingtips.com/books/"><img src="http://www.bloggingtips.com/ebooks/images/blogging-tips-books.png" alt="Blogging Tips Books"></a><br />
A selection of e-books to help you improve as a blogger.
Find out more at <a href="http://www.bloggingtips.com/books">www.bloggingtips.com/books/</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Now that we&#8217;ve covered a lot of information on <a href="http://www.bloggingtips.com/category/design-coding/">HTML</a> and some brief information on <a href="http://www.bloggingtips.com/category/design-coding/css/">CSS</a>, it&#8217;s now time to explore the power of CSS even more.</p>
<h3>Selectors</h3>
<p>Selectors allow you to target specific tags, ids, classes, attributes and more, on a page, ie. target a specific item or a group of items. We&#8217;ve seen and used these already briefly, to target type selectors (h1, div, p, a, etc), ID selectors (#idname) and class selectors (.classname).</p>
<p>The following is perfectly fine to use:</p>
<pre class="brush: css;">h1 { color: red; }
#redtext { color: red; }
.redtext { color: red; font-size: 10px }</pre>
<p>And to achieve the same effect we can use</p>
<pre class="brush: css;">h1, #redtext, .redtext { color: red; }
.redtext { font-size: 10px; }</pre>
<h3>Universal Selector</h3>
<p>The Universial selector is an asterisk &#8211; *</p>
<p>This selector, when used on its own, will target every element in a HTML document eg.</p>
<pre class="brush: css;">* { color: black }</pre>
<p>Which would then set all text to be the colour black unless you choose to override it with a more specific selector.</p>
<h3>Descendent Selectors</h3>
<p>Following on from this, we also have descendent selectors, whereby you can specifically target a selector within another selector eg.</p>
<pre class="brush: css;">.redtext { color: red }
#somediv p .redtext { color: blue; }</pre>
<p>This would mean anything with a class of &#8216;redtext&#8217; would be in red, however if it&#8217;s inside a paragraph within a div with the #somediv id, it would be blue instead.</p>
<h3>Child Selectors</h3>
<p>Child selectors are similar to descedant selectors except you are just targeting selectors that are direct children. The syntax of this is to use a greater-than sign eg.</p>
<pre class="brush: css;">#somediv &gt; p { color: red }</pre>
<p>Which would only change the text colour of paragraphs that are direct children of the somediv ID. For example. If you had markup similar to</p>
<pre class="brush: html;">&lt;div id=&quot;somediv&quot;&gt;
    &lt;p&gt;Paragraph 1&lt;/p&gt;
    &lt;div&gt;
        &lt;p&gt;Paragraph 2&lt;/p&gt;
    &lt;/div&gt;
&lt;/div&gt;</pre>
<p>With a descendant selector of &#8220;#somediv p&#8221; you would target both paragraphs, however with the child selector as above, you would only target the first paragraph, as the second one is not a direct child of the #somediv ID, but of the div within it.</p>
<p>You can also use descendant selectors with child selectors eg.</p>
<pre class="brush: css;">#somediv div &gt; p { color: red }</pre>
<p>Which would then target the second paragraph.</p>
<h3>Adjacent Sibiling Selectors</h3>
<p>These selectors allow you to target a selector that comes after a specific selector in the markup, and both have the same parent selector. For example, if you wanted to target the h2 that directly followed a h1 then you would use</p>
<pre class="brush: css;">h1 + h2 { color: red }</pre>
<p>This would only change the text of a h2 to red if it came straight after the h1 in markup. eg.</p>
<pre class="brush: html;">&lt;div id=&quot;wrapper&quot;&gt;
    &lt;h1&gt;Main Site Title&lt;/h1&gt;
    &lt;h2&gt;This header will be in red&lt;/h2&gt;
    &lt;p&gt;Something here&lt;/p&gt;

    &lt;h2&gt;This header won't be affected&lt;/h2&gt;
    &lt;p&gt;Something here&lt;/p&gt;

    &lt;div&gt;
        &lt;h1&gt;Another main title here&lt;/h1&gt;
    &lt;/div&gt;

    &lt;h2&gt;This header won't be affected either&lt;/h2&gt;
    &lt;p&gt;Something here&lt;/p&gt;
&lt;/div&gt;</pre>
<p>Next week I&#8217;ll explain attribute selectors and pseudo-elements and pseudo-classes.</p>
<hr>Copyright &copy; 2010 <strong><a href="http://www.bloggingtips.com">Blogging Tips</a></strong>. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. Please <a href=http://www.bloggingtips.com/contact/>contact us</a> so we can take legal action immediately.<p><a href="http://www.bloggingtips.com/2009/03/12/explaining-css-selectors-i/">Explaining CSS Selectors Part I</a><br /><br />
<a href="http://www.bloggingtips.com/books/"><img src="http://www.bloggingtips.com/ebooks/images/blogging-tips-books.png" alt="Blogging Tips Books"></a><br />
A selection of e-books to help you improve as a blogger.
Find out more at <a href="http://www.bloggingtips.com/books">www.bloggingtips.com/books/</a></p>
<img src="http://www.bloggingtips.com/?ak_action=api_record_view&id=5849&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.bloggingtips.com/2009/03/12/explaining-css-selectors-i/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Understanding the float property</title>
		<link>http://www.bloggingtips.com/2009/02/12/understanding-the-float-property/</link>
		<comments>http://www.bloggingtips.com/2009/02/12/understanding-the-float-property/#comments</comments>
		<pubDate>Thu, 12 Feb 2009 20:00:09 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://www.bloggingtips.com/?p=5553</guid>
		<description><![CDATA[To be able to control your layouts you need to understand the float property. I&#8217;ve briefly mentioned this before and given examples of how to use it but not actually explained it in full. Note, for the following examples I&#8217;ve used inline styles, purely to give you an example and show you the code used, [...]<p><a href="http://www.bloggingtips.com/2009/02/12/understanding-the-float-property/">Understanding the float property</a><br /><br />
<a href="http://www.bloggingtips.com/books/"><img src="http://www.bloggingtips.com/ebooks/images/blogging-tips-books.png" alt="Blogging Tips Books"></a><br />
A selection of e-books to help you improve as a blogger.
Find out more at <a href="http://www.bloggingtips.com/books">www.bloggingtips.com/books/</a></p>
]]></description>
			<content:encoded><![CDATA[<p>To be able to control your layouts you need to understand the float property. I&#8217;ve briefly mentioned this before and given examples of how to use it but not actually explained it in full. Note, for the following examples I&#8217;ve used inline styles, purely to give you an example and show you the code used, however, as always, external stylesheets should be used to reduce code, to create reusable code and to use CSS as it was intended for.</p>
<h3>Example Usage</h3>
<p>The float property allows you to control the position of specific elements and the content or other elements that follow. For example, you can position an image to the left of some content<sup>1</sup>, and have the content flow around the image, or you can make a horizontal menu by using a list and floating the items next to each other<sup>2</sup>.</p>
<h4>Example 1: Image and Content</h4>
<p><img src="http://www.bloggingtips.com/wp-content/avatars/57.jpg" alt="Sarah's Photo" style="float: left; margin: 0 5px 5px 0" /> Floating to the left of this content is a photo of yours truly. As you can see, this text flows around the image, similar to how the now deprecated align=&#8221;left&#8221; attribute used to work for images. This, of course, is just a simple example of usage however it&#8217;s very useful to use in blog posts or on standard content pages to have your image fitting in with the content nicely.</p>
<p>To create the above I&#8217;ve used the following code:</p>
<pre class="brush: html;">&lt;p&gt;&lt;img src=&quot;http://www.bloggingtips.com/wp-content/avatars/57.jpg&quot; alt=&quot;Sarah's Photo&quot; style=&quot;float: left; margin: 0 5px 5px 0&quot; /&gt;
Floating to the left of this content is a photo of yours truly. As you can see, this text flows around the image,
similar to how the now deprecated align=&quot;left&quot; attribute used to work for images.
This, of course, is just a simple example of usage however it's very useful to use in blog posts or on standard
content pages to have your image fitting in with the content nicely.&lt;/p&gt;</pre>
<h4>Example 2: Horizontal Menu</h4>
<ul style="list-style-type: none">
<li style="width: 100px; float: left; text-align: center;"><a href="#">Link 1</a></li>
<li style="width: 100px; float: left; text-align: center;"><a href="#">Link 2</a></li>
<li style="width: 100px; float: left; text-align: center;"><a href="#">Link 3</a></li>
<li style="width: 100px; float: left; text-align: center;"><a href="#">Link 4</a></li>
</ul>
<div class="clear"></div>
<p>The above example was created with the code:</p>
<pre class="brush: html;">&lt;ul style=&quot;list-style-type: none&quot;&gt;
&lt;li style=&quot;width: 100px; float: left; text-align: center;&quot;&gt;&lt;a href=&quot;#&quot;&gt;Link 1&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;width: 100px; float: left; text-align: center;&quot;&gt;&lt;a href=&quot;#&quot;&gt;Link 2&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;width: 100px; float: left; text-align: center;&quot;&gt;&lt;a href=&quot;#&quot;&gt;Link 3&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;width: 100px; float: left; text-align: center;&quot;&gt;&lt;a href=&quot;#&quot;&gt;Link 4&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</pre>
<p>The difference with this and the first example is that above I&#8217;ve had to give each list item a width. You usually need to give your floated element a width unless it already has a fixed width assigned (eg. like an image), else it will expand to fit the container it&#8217;s in, and then the float would be pointless.</p>
<h3>Clearing Floats</h3>
<p>Often, the side effect of using a float is that people don&#8217;t understand how to stop the float from taking over. For example, if you had an image floated to the left, with some content, then a second image to also float left, and content, you would probably want one image above the other regardless of content length, however I&#8217;m sure you&#8217;ve seen sites were people have ended up with:</p>
<p><img src="http://www.bloggingtips.com/wp-content/avatars/57.jpg" alt="Sarah's Photo" style="float: left; margin: 0 5px 10px 0" /> Floating to the left of this content is a photo of Sarah.</p>
<p><img src="http://www.bloggingtips.com/wp-content/avatars/1.jpg" alt="Kevin's Photo" style="float: left; margin: 0 5px 10px 0" /> Floating to the left of this content is a photo of Kevin.</p>
<div class="clear"></div>
<p>As you can see, this isn&#8217;t the desired outcome, so we need to <em>clear the float</em> using the clear property.</p>
<p>The clear property accepts 4 values, left, right, both or none. The property works by moving the element down until it&#8217;s clear of all floated properties to either the left, right or both, depending on which value is selected. Of course the none value is there to allow you to override a clear property if you need to (remember inheritance).</p>
<p>So to fix the example above we would need to clear the float for the second image and paragraph ie.</p>
<p><img src="http://www.bloggingtips.com/wp-content/avatars/57.jpg" alt="Sarah's Photo" style="float: left; margin: 0 5px 10px 0" /> Floating to the left of this content is a photo of Sarah.</p>
<p style="clear:left"><img src="http://www.bloggingtips.com/wp-content/avatars/1.jpg" alt="Kevin's Photo" style="float: left; margin: 0 5px 10px 0" /> Floating to the left of this content is a photo of Kevin.</p>
<div class="clear"></div>
<p>This has been fixed on the second paragraph using:</p>
<pre class="brush: css;">&lt;p style=&quot;clear:left&quot;&gt;...&lt;/p&gt;</pre>
<p>Often though you do not necessarily have an element to add the clear to, or you don&#8217;t want to have update every ruleset to add in a clear. So sometimes an easier fix is to create a class and just give that a property of clear eg.</p>
<pre class="brush: css;">.clearme {
    clear: both;
}</pre>
<p>Then, you can just add the clearme class where needed. If you don&#8217;t have an element to add the class to for some reason then you can also use an empty div eg.</p>
<pre class="brush: html;">&lt;div class=&quot;clearme&quot;&gt;&lt;/div&gt;</pre>
<p>There are more sophisticated ways of clearing floated elements, the above is a basic example but should give you an idea of how to keep floats under control.</p>
<h3>Conclusion</h3>
<p>This is a fairly advanced aspect of understanding CSS, but once you can grasp the logic behind floats then your layout control will be so much better and you&#8217;ll find coding up layouts much quicker and easier to do.</p>
<hr>Copyright &copy; 2010 <strong><a href="http://www.bloggingtips.com">Blogging Tips</a></strong>. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. Please <a href=http://www.bloggingtips.com/contact/>contact us</a> so we can take legal action immediately.<p><a href="http://www.bloggingtips.com/2009/02/12/understanding-the-float-property/">Understanding the float property</a><br /><br />
<a href="http://www.bloggingtips.com/books/"><img src="http://www.bloggingtips.com/ebooks/images/blogging-tips-books.png" alt="Blogging Tips Books"></a><br />
A selection of e-books to help you improve as a blogger.
Find out more at <a href="http://www.bloggingtips.com/books">www.bloggingtips.com/books/</a></p>
<img src="http://www.bloggingtips.com/?ak_action=api_record_view&id=5553&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.bloggingtips.com/2009/02/12/understanding-the-float-property/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>CSS Basics: List Properties II and a Horizontal Menu</title>
		<link>http://www.bloggingtips.com/2009/01/01/css-basics-list-properties-ii/</link>
		<comments>http://www.bloggingtips.com/2009/01/01/css-basics-list-properties-ii/#comments</comments>
		<pubDate>Thu, 01 Jan 2009 20:00:07 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://www.bloggingtips.com/?p=4996</guid>
		<description><![CDATA[Last week I wrote about the specific CSS list properties. This week I&#8217;m going to cover some of the positioning properties that are useful with lists but can be used with other html elements as well.
Margins and Padding
Every element can have both a margin and padding given to it, i.e.
 Here the element ends at [...]<p><a href="http://www.bloggingtips.com/2009/01/01/css-basics-list-properties-ii/">CSS Basics: List Properties II and a Horizontal Menu</a><br /><br />
<a href="http://www.bloggingtips.com/books/"><img src="http://www.bloggingtips.com/ebooks/images/blogging-tips-books.png" alt="Blogging Tips Books"></a><br />
A selection of e-books to help you improve as a blogger.
Find out more at <a href="http://www.bloggingtips.com/books">www.bloggingtips.com/books/</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Last week I wrote about the specific <a href="http://www.bloggingtips.com/2008/12/25/css-basics-list-properties/">CSS list properties</a>. This week I&#8217;m going to cover some of the positioning properties that are useful with lists but can be used with other html elements as well.</p>
<h3>Margins and Padding</h3>
<p>Every element can have both a margin and padding given to it, i.e.</p>
<p><img style=' float: left; padding: 4px; margin: 0 7px 2px 0;'  src="http://www.bloggingtips.com/wp-content/uploads/2009/01/margin-padding.gif" alt="Margin/Padding Example" width="210" height="150" class="alignleft" /> Here the element ends at the border, then the margin is the spacing outside of the border, and the padding is the spacing between the border and the content.</p>
<p>Both properties are similar to use. For example with the margin property you can use</p>
<pre class="brush: css;">ul {
    margin-top: 10px;
    margin-right: 0;
    margin-bottom: 5px;
    margin-left: 20px;
}</pre>
<p>Or you can use the shorthand version:</p>
<pre class="brush: css;">ul {
    margin: 10px 0 5px 20px;
}</pre>
<p>As explained before on <a href="http://www.bloggingtips.com/2008/12/11/html-basics-images/">HTML Basics: Images</a>, the margin property can accept 1, 2, 3 or 4 values:</p>
<ul>
<li>1 value: Sets the margin for all sides ie. the top, right, bottom and left margins.</li>
<li>2 values: The first value sets the top and bottom margins, the second sets the left and right margins.</li>
<li>3 values: The first value sets the top margin, the second sets the left and right margin, the third sets the bottom margin.</li>
<li>4 values: Sets the margin values in the order top right bottom left.</li>
</ul>
<p>To use the padding property, you use virtually the same property except you swap &#8216;margin&#8217; with &#8216;padding&#8217; eg.</p>
<pre class="brush: css;">ul {
    padding: 10px 0 5px 20px;
}
li {
    padding-top: 5px;
}</pre>
<p>By default lists have a predefined amount of margin and padding, so these are two properties that you&#8217;ll often want to alter in your CSS to get them to fit into your design.</p>
<p><em>Box Model image courtesy of <a href="http://www.ap4a.co.uk">David Anderson</a></em>.</p>
<h3>Horizontal Menu</h3>
<p>Lists are often used (and rightly so!) for navigation, however the horizontal navigation is often a bit tricky for some, when the basics are fairly straightforward. First of all, we need a menu eg.</p>
<pre class="brush: html;">&lt;div class=&quot;nav&quot;&gt;
    &lt;ul&gt;
        &lt;li class=&quot;current_page_item&quot;&gt;&lt;a href=&quot;http://www.bloggingtips.com/&quot; title=&quot;Blogging Tips&quot;&gt;Home&lt;/a&gt;&lt;/li&gt;
        &lt;li class=&quot;page_item page_item_3&quot;&gt;&lt;a href=&quot;http://www.bloggingtips.com/forums/&quot;&gt;Forums&lt;/a&gt;&lt;/li&gt;
        &lt;li class=&quot;page_item page_item_8&quot;&gt;&lt;a href=&quot;http://www.bloggingtips.com/forums/local_links.php&quot;&gt;Directory&lt;/a&gt;&lt;/li&gt;
	&lt;li class=&quot;page_item page_item_7&quot;&gt;&lt;a href=&quot;http://www.bloggingtips.com/themes/&quot;&gt;Themes&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
&lt;/div&gt;</pre>
<p>Then we need to remove the bullets from the menu, and remove the margin and padding, so that we can start with a clean slate. To do this we use</p>
<pre class="brush: css;">#nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
}</pre>
<p>Finally we need to give each list item a width and then we use the float property, which allows us to float each list item next to each other (the float property will be explained in depth in the future). To do this we can use the following CSS</p>
<pre class="brush: css;">#nav li {
    float: left;
    width: 100px;
}</pre>
<p>And from a basic point of view, that&#8217;s all there is to it! The code above gives each list item a width of 100 pixels, and then using the float property with a value of left, each item gets floated left, then the next item is positioned next to it. You can see this in action on the <a href='http://www.bloggingtips.com/wp-content/uploads/2009/01/menu1.html'>basic menu example</a>.</p>
<p>Of course, this doesn&#8217;t look very pretty, so we can jazz this up a little with the following CSS</p>
<pre class="brush: css;">#nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
}
#nav li {
    float: left;
    width: 75px;
    margin: 0 1px;
    background: #900;
    text-align: center;
    border: 1px solid #009;
}
#nav a {
    color: #fff;
    display: block;
    text-decoration: none;
    padding: 2px 0 3px;
}
#nav a:hover {
    background: #000;
}</pre>
<p>Here I&#8217;ve added some extra styles to the list item, to put a slight gap between each item using the margin property, given the list items a background colour and border to give it a more button look. Then for the links they&#8217;ve had the colour changed to white, the underline removed and have a bit of padding. I&#8217;ve also used display: block, which we&#8217;ve not used before. This changes the link from inline, meaning just the text is clickable, to making the whole containing element (ie. the list item in this case) clickable. It makes the link more of a button. As a final touch I&#8217;ve set the background of the link to change on hover.</p>
<p>You can see this example in the second <a href='http://www.bloggingtips.com/wp-content/uploads/2009/01/menu2.html'>menu example</a>.</p>
<p>As you can see, the posts from the past few weeks on the <a href="http://www.bloggingtips.com/category/design-coding/">HTML and CSS Basics</a> are starting to give us enough to be able to understand and create some intermediate solutions <img src='http://www.bloggingtips.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<hr>Copyright &copy; 2010 <strong><a href="http://www.bloggingtips.com">Blogging Tips</a></strong>. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. Please <a href=http://www.bloggingtips.com/contact/>contact us</a> so we can take legal action immediately.<p><a href="http://www.bloggingtips.com/2009/01/01/css-basics-list-properties-ii/">CSS Basics: List Properties II and a Horizontal Menu</a><br /><br />
<a href="http://www.bloggingtips.com/books/"><img src="http://www.bloggingtips.com/ebooks/images/blogging-tips-books.png" alt="Blogging Tips Books"></a><br />
A selection of e-books to help you improve as a blogger.
Find out more at <a href="http://www.bloggingtips.com/books">www.bloggingtips.com/books/</a></p>
<img src="http://www.bloggingtips.com/?ak_action=api_record_view&id=4996&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.bloggingtips.com/2009/01/01/css-basics-list-properties-ii/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>CSS Basics: List Properties</title>
		<link>http://www.bloggingtips.com/2008/12/25/css-basics-list-properties/</link>
		<comments>http://www.bloggingtips.com/2008/12/25/css-basics-list-properties/#comments</comments>
		<pubDate>Thu, 25 Dec 2008 20:00:03 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://www.bloggingtips.com/?p=4898</guid>
		<description><![CDATA[Last week I covered the HTML Basics for using Lists. This week and next, we will cover the CSS properties for use with lists.
List Specific Properties
We have 3 properties that are specifically for unordered and ordered lists.
list-style-type
The list-style-type property allows you to control the appearance of the list &#8216;marker&#8217; ie. the bullet point style for [...]<p><a href="http://www.bloggingtips.com/2008/12/25/css-basics-list-properties/">CSS Basics: List Properties</a><br /><br />
<a href="http://www.bloggingtips.com/books/"><img src="http://www.bloggingtips.com/ebooks/images/blogging-tips-books.png" alt="Blogging Tips Books"></a><br />
A selection of e-books to help you improve as a blogger.
Find out more at <a href="http://www.bloggingtips.com/books">www.bloggingtips.com/books/</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Last week I covered the <a href="http://www.bloggingtips.com/2008/12/18/html-basics-using-lists/">HTML Basics for using Lists</a>. This week and next, we will cover the CSS properties for use with lists.</p>
<h2>List Specific Properties</h2>
<p>We have 3 properties that are specifically for unordered and ordered lists.</p>
<h3>list-style-type</h3>
<p>The list-style-type property allows you to control the appearance of the list &#8216;marker&#8217; ie. the bullet point style for unordered lists or the numbering system for an ordered list. For both types of lists you can have the values of inherit or none. The latter will remove the bullet/number altogether.</p>
<p>For an unordered list you can select to have a value of disc, circle or square e.g.</p>
<pre class="brush: css;">ul.squarelist {
    list-style-type: square;
}
ul.disclist {
    list-style-type: disc;
}</pre>
<p>For an ordered list you can use the following property values:</p>
<dl>
<dt>decimal</dt>
<dd>Sequential numbers starting from 1</dd>
<dt>decimal-leading-zero</dt>
<dd>Sequential numbers starting from 0</dd>
<dt>lower-roman</dt>
<dd>Lowercase roman numerals &#8211; i, ii, iii, iv, v etc.</dd>
<dt>upper-roman</dt>
<dd>Uppercase roman numerals</dd>
<dt>lower-greek</dt>
<dd>Lowercase greek alphabet &#8211; α, β, γ etc.</dd>
<dt>lower-latin</dt>
<dd>Lowercase latin alphabet &#8211; a, b, c, d, e etc.</dd>
<dt>upper-latin</dt>
<dd>Uppercase latin alphabet</dd>
<dt>armenian</dt>
<dd>Armenian numbering</dd>
<dt>georgian</dt>
<dd>Georgian numbering</dd>
</dl>
<p>Example usage of these would be</p>
<pre class="brush: css;">ol.roman {
    list-style-type: lower-roman;
}
ol.alpha {
    list-style-type: lower-latin;
}</pre>
<p>Giving</p>
<ol style="list-style-type: lower-roman">
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ol>
<p>and</p>
<ol style="list-style-type: lower-latin">
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ol>
<h3>list-style-image</h3>
<p>For unordered lists, you can also specify an image to use for the bullet point. The property value is the same as setting a background image ie.</p>
<pre class="brush: css;">ul {
    list-style-image: url(&quot;http://www.domain.com/path/to/file/bullet.gif&quot;);
}</pre>
<p>This will then display as the bullet point instead of the bullet point, providing you haven&#8217;t set the list-style-type value to &#8216;none&#8217;.</p>
<h3>list-style-position</h3>
<p>Finally the third list specific property is the position of the marker. By default you have a bullet point away from the block of text which is the value &#8216;outside&#8217;, however you can also give the property value of &#8216;inside&#8217; to bring the bullet point into the block of text for each list item i.e.</p>
<h4>Outside Position</h4>
<pre class="brush: css;">ul.outside {
    list-style-position: outside;
}</pre>
<ul style="list-style-positon: outside">
<li>First item<br />
First item, second line</li>
<li>Second item<br />
Second item, second line</li>
</ul>
<h4>Inside Position</h4>
<pre class="brush: css;">ul.inside {
    list-style-position: inside;
}</pre>
<ul style="list-style-position: inside">
<li>First item<br />
First item, second line</li>
<li>Second item<br />
Second item, second line</li>
</ul>
<p>As you can see, the second list has the bullet within the block of text.</p>
<h3>list-style</h3>
<p>The list-style property allows you to combine all 3 list style properties in one property. There is no specific order for these property values e.g.</p>
<pre class="brush: css;">ul {
    list-style: circle inside url(&quot;images/square-bullet.gif&quot;);
}</pre>
<p>This would give your unordered lists circle bullet points, positioned inside the list item block, and would use the square-bullet.gif image for the bullet point (which would then replace the circle bullet points providing the image loads).</p>
<h2>Additional CSS Properties</h2>
<p>Lists can also use the standard <a href="http://www.bloggingtips.com/2008/11/27/css-basics-the-background-properties/">background</a> and <a href="http://www.bloggingtips.com/2008/12/04/css-basics-font-styling/">font styling</a> properties, along with certain positioning properties which will be covered next week.</p>
<hr>Copyright &copy; 2010 <strong><a href="http://www.bloggingtips.com">Blogging Tips</a></strong>. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. Please <a href=http://www.bloggingtips.com/contact/>contact us</a> so we can take legal action immediately.<p><a href="http://www.bloggingtips.com/2008/12/25/css-basics-list-properties/">CSS Basics: List Properties</a><br /><br />
<a href="http://www.bloggingtips.com/books/"><img src="http://www.bloggingtips.com/ebooks/images/blogging-tips-books.png" alt="Blogging Tips Books"></a><br />
A selection of e-books to help you improve as a blogger.
Find out more at <a href="http://www.bloggingtips.com/books">www.bloggingtips.com/books/</a></p>
<img src="http://www.bloggingtips.com/?ak_action=api_record_view&id=4898&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.bloggingtips.com/2008/12/25/css-basics-list-properties/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>CSS Basics: Font Styling</title>
		<link>http://www.bloggingtips.com/2008/12/04/css-basics-font-styling/</link>
		<comments>http://www.bloggingtips.com/2008/12/04/css-basics-font-styling/#comments</comments>
		<pubDate>Thu, 04 Dec 2008 20:00:11 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://www.bloggingtips.com/?p=4591</guid>
		<description><![CDATA[Let&#8217;s face it, the default settings on browsers are hardly great for the look of your site. So next step, with your HTML page, is to add in some font styling.
The Font Properties
Font properties work on any selector that contains text. Most font properties are easy to spot as they start with the word &#8216;font&#8217;, [...]<p><a href="http://www.bloggingtips.com/2008/12/04/css-basics-font-styling/">CSS Basics: Font Styling</a><br /><br />
<a href="http://www.bloggingtips.com/books/"><img src="http://www.bloggingtips.com/ebooks/images/blogging-tips-books.png" alt="Blogging Tips Books"></a><br />
A selection of e-books to help you improve as a blogger.
Find out more at <a href="http://www.bloggingtips.com/books">www.bloggingtips.com/books/</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s face it, the default settings on browsers are hardly great for the look of your site. So next step, with your HTML page, is to add in some font styling.</p>
<h2>The Font Properties</h2>
<p>Font properties work on any selector that contains text. Most font properties are easy to spot as they start with the word &#8216;font&#8217;, however our first selector is simply &#8216;color&#8217; (and our last selector is line-height). This is one point to remember, as &#8216;font-color&#8217; will not work!</p>
<h3>color</h3>
<p>We&#8217;ve seen the color property when <a href="http://www.bloggingtips.com/2008/11/20/css-basics-styling-links/">styling page links</a> a couple of weeks ago. This property allows you to set the color of the text within the target selector, and accepts the hexadecimal, RGB and pre-defined colour names, as a value.</p>
<p>As briefly mentioned last week, it&#8217;s recommended to always set a background colour when setting a font colour, so that you can be certain if something else doesn&#8217;t load, or for some other reason, your text will always be readable.</p>
<p>So an example of use would be</p>
<pre class="brush: css;">body {
    color: black;
    background: white;
}
h1 {
    color: navy;
    background: white;
}
p {
    color: white;
    background: navy;
}</pre>
<p>The above sets the body properties to have black text with a white background. All selectors within the body (ie. everything on the page except for links) will inherit this if they&#8217;re not specifically set further down in the stylesheet. I&#8217;ve then set all h1 headers to be in a navy blue, and then all paragraphs of content will have a navy background with white text.</p>
<h3>font-family</h3>
<p>This sets the font to be used for the text. It takes a comma separated list of fonts, and the priority reads from left to right. If the user doesn&#8217;t have the first font specified, it will try the next and the next until a match is found. However, it&#8217;s widely recommended to ensure that one of the fall back fonts is a &#8216;web safe&#8217; font, which are fonts that are generally available on the default installations of computers. You should also have the last font in the list as a generic family name, such as serif or sans-serif.</p>
<p>For multiple word names, eg. Times New Roman, these should be surrounded by quotes ie. &#8220;Times New Roman&#8221;. An example of this is</p>
<pre class="brush: css;">body {
    font-family: Verdana, &quot;Times New Roman&quot;, sans-serif;
}</pre>
<p>If you want to use the Arial font, then also specify Helvetica for Mac Users, which is their equivalent e.g.</p>
<pre class="brush: css;">body {
    font-family: Arial, Helvetica, &quot;Times New Roman&quot;, sans-serif;
}</pre>
<h3>font-size</h3>
<p>This controls the size of the text. It can accept a value in pixels (px), em, ex or a percentage (it can also accept a numerical value in mm, cm, inches, points (pt) and pc, however it&#8217;s not recommended to use these length measurements). It can also accept one of a number of predefined values &#8211; xx-small, x-small, small, medium, large, x-large, xx-large, smaller, larger, inherit.</p>
<pre class="brush: css;">body { font-size: 12px; }
p { font-size: 11px; }</pre>
<h3>font-style</h3>
<p>This allows you to effectively set the font to be italic or not. It accepts one of 4 values, italic, normal, oblique or inherit.</p>
<pre class="brush: css;">body { font-style: italic; }
p { font-style: none; }</pre>
<h3>font-variant</h3>
<p>This allows you to set the font to display in small capitals or not. It accepts one of 3 values, small-caps, normal, inherit.</p>
<pre class="brush: css;">h1 { font-variant: small-caps; }</pre>
<h3>font-weight</h3>
<p>This sets the font weight of the text. It accepts the values lighter, normal, bold, bolder or a number of either 100, 200, 300, through to 900 (multiples of 100) &#8211; however the support for numbers is quite inconsistent across browsers.</p>
<p>An example of use would be</p>
<pre class="brush: css;">a { font-weight: bold }
a:visited { font-weight: normal }</pre>
<h3>line-height</h3>
<p>This is our other selector for fonts that doesn&#8217;t start with &#8216;font&#8217;. The line-height selector controls the height of the line that the text sits in. If the line-height given is larger than the font size specified, then the text is vertically centered within the given line-height ie. a font size of 10px with a line height of 20px will mean that there will be 5px of white space above and below the text eg.</p>
<pre class="brush: css;">p#specificdiv {
    font-size: 10px;
    line-height: 20px;
}</pre>
<h2>Font Shorthand</h2>
<p>As with the <a href="http://www.bloggingtips.com/2008/11/27/css-basics-the-background-properties/">background properties</a>, we have a shorthand version for the font properties (this doesn&#8217;t include color). Using this is slightly stricter than the background shorthand however. A full example is</p>
<pre class="brush: css;">body {
    font: italics bold small-caps 10px/15px Arial, Helvetica, sans-serif;
}</pre>
<p>This is in the order of font-style font-weight font-variant font-size/line-height font-family.</p>
<p>You can omit all of these besides font-size and font-family, which are always required when using the font property. Also, ensure that the last two values, regardless of what else is used, are the font-size (with or without the line-height) and the font family. Any of the following examples would be fine to use</p>
<pre class="brush: css;">body {
    font: 12px Arial, Helvetica, sans-serif;
}
p#specificdiv {
    font: italics bold 11px Arial, Helvetica, sans-serif;
}
h1 {
    font: small-caps 14px/18px Arial, Helvetica, sans-serif;
}</pre>
<p>For the items not set, the default of normal is automatically used, so even if the body selector has a italics setting, if the font property is used on the h1 and it doesn&#8217;t specify italics then it will be reset to normal and not inherit the italics value.</p>
<p>Next week I&#8217;ll go back to the HTML basics and continue through some more mark up to allow you to improve on your basic understanding, or understand your current theme a little more!</p>
<hr>Copyright &copy; 2010 <strong><a href="http://www.bloggingtips.com">Blogging Tips</a></strong>. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. Please <a href=http://www.bloggingtips.com/contact/>contact us</a> so we can take legal action immediately.<p><a href="http://www.bloggingtips.com/2008/12/04/css-basics-font-styling/">CSS Basics: Font Styling</a><br /><br />
<a href="http://www.bloggingtips.com/books/"><img src="http://www.bloggingtips.com/ebooks/images/blogging-tips-books.png" alt="Blogging Tips Books"></a><br />
A selection of e-books to help you improve as a blogger.
Find out more at <a href="http://www.bloggingtips.com/books">www.bloggingtips.com/books/</a></p>
<img src="http://www.bloggingtips.com/?ak_action=api_record_view&id=4591&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.bloggingtips.com/2008/12/04/css-basics-font-styling/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>CSS Basics: The Background Properties</title>
		<link>http://www.bloggingtips.com/2008/11/27/css-basics-the-background-properties/</link>
		<comments>http://www.bloggingtips.com/2008/11/27/css-basics-the-background-properties/#comments</comments>
		<pubDate>Thu, 27 Nov 2008 20:00:22 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://www.bloggingtips.com/?p=4449</guid>
		<description><![CDATA[Last week I briefly touched on a few selector properties when styling hyperlinks. I&#8217;m going to start to go into more properties. These properties can be used on any selector (although not every property will necessarily have an effect on some selectors).
CSS Selectors
Just to recap, a selector is the tag, id or class you&#8217;re targeting [...]<p><a href="http://www.bloggingtips.com/2008/11/27/css-basics-the-background-properties/">CSS Basics: The Background Properties</a><br /><br />
<a href="http://www.bloggingtips.com/books/"><img src="http://www.bloggingtips.com/ebooks/images/blogging-tips-books.png" alt="Blogging Tips Books"></a><br />
A selection of e-books to help you improve as a blogger.
Find out more at <a href="http://www.bloggingtips.com/books">www.bloggingtips.com/books/</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Last week I briefly touched on a few selector properties when <a href="http://www.bloggingtips.com/2008/11/20/css-basics-styling-links/">styling hyperlinks</a>. I&#8217;m going to start to go into more properties. These properties can be used on any selector (although not every property will necessarily have an effect on some selectors).</p>
<h2>CSS Selectors</h2>
<p>Just to recap, a selector is the tag, id or class you&#8217;re targeting eg.</p>
<pre class="brush: css;">h1 { ... }
#idname { ... }
.classname { ... }</pre>
<p>and multiple selectors can be used, using a comma to separate them</p>
<pre class="brush: css;">h1, #idname { ... }</pre>
<p>or you can target a selector more specifically with a space between each descendant</p>
<pre class="brush: css;">body div h1 { ... }</pre>
<h2>Properties and Values</h2>
<p>In the rule set for the selector(s) you have properties and values. An example ruleset is</p>
<pre class="brush: css;">selector {
    property: value;
    property2: value1 value2;
}</pre>
<h2>The Background Properties</h2>
<p>A background can be changed on virtually any selector, although it&#8217;s not always wise to do so! You can change the background to a different colour, or have an image displaying instead.</p>
<p>The background properties allow you to change the background colour and/or image of the selector.  The individual properties and their values are listed below.</p>
<h3>background-color</h3>
<p>Allows you to set the background colour of the selector. Accepts a hexadecimal colour eg. #aabbcc (when you have matching pairs, this can also be written as #abc), specific colour names eg. white, black, RGB colours eg. rgb(255, 255, 255). Finally it can also accept the value &#8216;transparent&#8217;. e.g.</p>
<pre class="brush: css;">h1 { background-color: #000; }
h2 { background-color: black; }
h3 { background-color: rgb(0, 0, 0); }
h4 { background-color: transparent; }</pre>
<h3>background-image</h3>
<p>Background images are most commonly seen on the body selector, however they can be used on plenty of other selectors too. This property accept &#8216;none&#8217; or a url to a background image eg.</p>
<pre class="brush: css;">body { background-image: none; }
body { background-image: url(/path/to/images/background.gif); }</pre>
<h3>background-attachment</h3>
<p>Allows you to control whether a background image is fixed or scolls with the page. Accepts two values &#8211; scroll or fixed. When you fix a background it is fixed to the viewport and not to the selector, regardless of which selector is used.</p>
<pre class="brush: css;">body { background-attachment: fixed; }
body { background-attachment: scroll; }</pre>
<h3>background-position</h3>
<p>Controls the starting position of the background image. Typically a background will be fixed to the top left corner (0,0 &#8211; x,y co-ordinates), however with this property you can change this starting point using co-ordinate positions with a measurement, percentages for the horizontal and vertical positioning, or keywords &#8211; top, bottom, left, right and center. e.g.</p>
<pre class="brush: css;">/* would start the background image at 100px from the top and left side of the browser */
body { background-position: 100px, 100px; }
/* both of the following would start the image halfway across the page and at the top */
body { background-position: 50% 0%; }
body { background-position: center top; }</pre>
<h3>background-repeat</h3>
<p>This controls how the background image is repeated. The options are a continual repeat/tiling, which is default, then you have the option of no repeat, to repeat horizontally only, or to repeat vertically only. e.g.</p>
<pre class="brush: css;">/* This sets the background image to repeat */
body { background-repeat: repeat; }
/* this would repeat the image horizontally from the starting point */
body { background-repeat: repeat-x; }
/* this would repeat the image vertically from the starting point */
body { background-repeat: repeat-y; }
/* this would display the background image just once, at the starting point specified by the position property */
body { background-repeat: no-repeat; }</pre>
<h2>The Shorthand Property</h2>
<p>Using the properties above you could set the background of a body selector to be white, display a fixed background image and have it repeating down the right hand side of the page using the following ruleset:</p>
<pre class="brush: css;">body {
    background-color: #fff;
    background-image: url(/images/backgrounds/background.gif);
    background-attachment: fixed;
    background-position: top right;
    background-repeat: repeat-y;
}</pre>
<p>However, that&#8217;s a lot of typing for one ruleset! Luckily we also have a short hand property that can combine one or more of these properties. The <strong>background</strong> property accepts one or more of the values used above, in no strict order. So to replicate the above we could use</p>
<pre class="brush: css;">body {
    background: #fff url(/images/backgrounds/background.gif) fixed top right repeat-y;
}</pre>
<p>If we just wanted to set the background colour we could use</p>
<pre class="brush: css;">body {
    background: #fff;
}</pre>
<p>Alternatively, you could just set a background image to display in the top left of the screen, once.</p>
<pre class="brush: css;">body {
    background: url(/images/backgrounds/background.gif) fixed no-repeat;
}</pre>
<p>Next week I&#8217;ll be explaining how you can style your text, however to allow you to get started with using the background property you of course need to be able to ensure your text can be read on top of it! So to do this we use the color selector, seen last week with styling links. To set the text colour of any selector we use this property. So for example, a white background with black text, and then paragraphs with white text on a black background could be</p>
<pre class="brush: css;">body {
    background: #fff;
    color: #000;
}
p {
    background: #000;
    color: #fff;
}</pre>
<p>Whatever you do, just make sure your text is always readable. As a guideline from the <abbr title="World Wide Web Consortium">W3C</abbr>, if you set a background colour you should always set a font colour (with enough contrast between to the two), and vice versa. This is to ensure that no defaults get in the way, or if you also set a background image, and the image didn&#8217;t display, then you would have a suitable background colour to ensure the text can be seen.</p>
<p>For a good example of how backgrounds can be used have a look at Eric Meyer&#8217;s <a href="http://meyerweb.com/eric/css/edge/complexspiral/demo.html">Complexspiral Demo</a>.</p>
<hr>Copyright &copy; 2010 <strong><a href="http://www.bloggingtips.com">Blogging Tips</a></strong>. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. Please <a href=http://www.bloggingtips.com/contact/>contact us</a> so we can take legal action immediately.<p><a href="http://www.bloggingtips.com/2008/11/27/css-basics-the-background-properties/">CSS Basics: The Background Properties</a><br /><br />
<a href="http://www.bloggingtips.com/books/"><img src="http://www.bloggingtips.com/ebooks/images/blogging-tips-books.png" alt="Blogging Tips Books"></a><br />
A selection of e-books to help you improve as a blogger.
Find out more at <a href="http://www.bloggingtips.com/books">www.bloggingtips.com/books/</a></p>
<img src="http://www.bloggingtips.com/?ak_action=api_record_view&id=4449&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.bloggingtips.com/2008/11/27/css-basics-the-background-properties/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>CSS Basics: Styling Links</title>
		<link>http://www.bloggingtips.com/2008/11/20/css-basics-styling-links/</link>
		<comments>http://www.bloggingtips.com/2008/11/20/css-basics-styling-links/#comments</comments>
		<pubDate>Thu, 20 Nov 2008 20:00:37 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://www.bloggingtips.com/?p=4345</guid>
		<description><![CDATA[Last week I explained about linking pages using the anchor tag. This week is about styling those links. For the basics of styling read my previous post Understanding CSS.
Target the anchor tag
In our CSS we can simply target the anchor tag using the a as the selector. So if we wanted our links to always [...]<p><a href="http://www.bloggingtips.com/2008/11/20/css-basics-styling-links/">CSS Basics: Styling Links</a><br /><br />
<a href="http://www.bloggingtips.com/books/"><img src="http://www.bloggingtips.com/ebooks/images/blogging-tips-books.png" alt="Blogging Tips Books"></a><br />
A selection of e-books to help you improve as a blogger.
Find out more at <a href="http://www.bloggingtips.com/books">www.bloggingtips.com/books/</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Last week I explained about <a href="http://www.bloggingtips.com/2008/11/13/html-basics-linking-pages/">linking pages</a> using the anchor tag. This week is about styling those links. For the basics of styling read my previous post <a href="http://www.bloggingtips.com/2008/10/23/understanding-css/">Understanding CSS</a>.</p>
<h3>Target the anchor tag</h3>
<p>In our CSS we can simply target the anchor tag using the <strong>a</strong> as the selector. So if we wanted our links to always be green and bold we could use</p>
<pre class="brush: css;">a {
    color: green;
    font-weight: bold;
}</pre>
<p>If you wanted to have links in a div with the id of topmenu to be white (because perhaps the topmenu has a black background) but all other links to be in blue then we could have</p>
<pre class="brush: css;">a {
    color: blue;
}

#topmenu a {
    color: white;
}</pre>
<p>Notice here, the first ruleset uses just <b>a</b> as the selector. This means all anchor links. However, the second ruleset uses <b>#topmenu a</b> as the selector, and this means all anchor links enclosed in the element with an id of topmenu i.e.</p>
<pre class="brush: html;">&lt;div id=&quot;topmenu&quot;&gt;
   &lt;a href=&quot;/&quot;&gt;Home&lt;/a&gt; | &lt;a href=&quot;about.htm&quot;&gt;About&lt;/a&gt; | &lt;a href=&quot;contact.htm&quot;&gt;Contact&lt;/a&gt;
&lt;/div&gt;</pre>
<p>By putting the &#8216;#topmenu a&#8217; ruleset second you automatically override the properties in the first ruleset with the second ruleset&#8217;s property values. This means that the colour is set in the first ruleset and the second ruleset overrides the colour for that particular selector. However, if you set perhaps the font weight to be bold in the first ruleset, if you didn&#8217;t specify anything for the font weight in the second ruleset then it would inherit the font weight setting from the first ruleset.</p>
<p>So to recap:</p>
<ul>
<li>Single tag selectors apply to every instance of that tag on a page eg. a, p, h1, div</li>
<li>You can override some or all properties by specifying a second (anywhere later in the file), more targeted selector eg. #idname a, #content p</li>
<li>Any properties not specified in the second ruleset will automatically be inherited from any rulesets already applied to that tag.</li>
</ul>
<p>If, for example, you had a top menu with a black background colour and a side menu with a blue background colour, and you wanted white links in the top menu, yellow links in the side menu, and blue links everywhere else, but you wanted bold links for the side menu and the page links then you would use</p>
<pre class="brush: css;">a {
    color: blue;
    font-weight: bold;
}

#topmenu a {
    color: white;
    font-weight: normal;
}

#sidemenu a {
    color: yellow;
}</pre>
<p>As you can see here, the topmenu links have had both their colour and font weight over written, whereas the sidemenu just has the colour changed. Both the topmenu and the sidemenu will only inherit their rules from the first ruleset for the anchor tag. The sidemenu ruleset will not inherit anything from the topmenu ruleset as they are unrelated, so the order of these two rulesets has no bearing on the outcome.</p>
<h3>Styling Link States</h3>
<p>With page links we can go one step further and style the different states for a hyperlink. A hyperlink typically has 5 states which we target using pseudo-classes:</p>
<dl>
<dt>:link</dt>
<dd>The state for a link that has not yet been visited</dd>
<dt>:visited</dt>
<dd>The state of a visited link</dd>
<dt>:hover</dt>
<dd>The state of a link when the mouse is hovering over it</dd>
<dt>:active</dt>
<dd>The state of a link when it is being clicked</dd>
<dt>:focus</dt>
<dd>The state of a link when it is selected but hasn&#8217;t been clicked (this is unsupported in current versions of Internet Explorer)</dd>
</dl>
<p>These pseudo-classes are not just limited to the anchor tag in browsers that support them (such as Internet Explorer 7, Firefox and Opera).</p>
<p>So now we can specify what colour link to use before and after the link has been visited, and we can also have the link change to a third, different colour, when someone hovers their mouse over it. So, for example, we could have all links, in all states, in bold, and then we&#8217;d have non visited, visited and hover states in blue, purple and red respectively. To do this we&#8217;d use</p>
<pre class="brush: css;">a {
    font-weight: bold;
}
a:link {
    color: blue;
}
a:visited {
    color: purple;
}
a:hover {
    color: red;
}</pre>
<p>Another common property with links is the text-decoration which is used to control whether a link is underlined or not. Often you&#8217;ll see sites with non underlined links until you hover over them. To achieve this we can use the following:</p>
<pre class="brush: css;">a {
    font-weight: bold;
    text-decoration: none;
}
a:link {
    color: blue;
}
a:visited {
    color: purple;
}
a:hover {
    color: red;
    text-decoration: underline;
}</pre>
<p>The other values that the text-decoration property can have besides none and underline are overline, line-through, blink and inherit (although I wouldn&#8217;t ever recommend using blink as it&#8217;s just distracting).</p>
<p>You can set other properties on links such as a background colour, font size, font family and more. Next week I&#8217;ll explain more of these properties and how they can be used.</p>
<hr>Copyright &copy; 2010 <strong><a href="http://www.bloggingtips.com">Blogging Tips</a></strong>. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. Please <a href=http://www.bloggingtips.com/contact/>contact us</a> so we can take legal action immediately.<p><a href="http://www.bloggingtips.com/2008/11/20/css-basics-styling-links/">CSS Basics: Styling Links</a><br /><br />
<a href="http://www.bloggingtips.com/books/"><img src="http://www.bloggingtips.com/ebooks/images/blogging-tips-books.png" alt="Blogging Tips Books"></a><br />
A selection of e-books to help you improve as a blogger.
Find out more at <a href="http://www.bloggingtips.com/books">www.bloggingtips.com/books/</a></p>
<img src="http://www.bloggingtips.com/?ak_action=api_record_view&id=4345&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.bloggingtips.com/2008/11/20/css-basics-styling-links/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Understanding CSS</title>
		<link>http://www.bloggingtips.com/2008/10/23/understanding-css/</link>
		<comments>http://www.bloggingtips.com/2008/10/23/understanding-css/#comments</comments>
		<pubDate>Thu, 23 Oct 2008 20:00:15 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://www.bloggingtips.com/?p=3651</guid>
		<description><![CDATA[CSS stands for Cascading Style Sheets. Its job is to control the presentation of a web page document, written in (x)HTML. The idea is that your web document, written in (x)HTML, contains the content and structure of your page, and then you apply the CSS to give the page colour and layout, keeping content separate [...]<p><a href="http://www.bloggingtips.com/2008/10/23/understanding-css/">Understanding CSS</a><br /><br />
<a href="http://www.bloggingtips.com/books/"><img src="http://www.bloggingtips.com/ebooks/images/blogging-tips-books.png" alt="Blogging Tips Books"></a><br />
A selection of e-books to help you improve as a blogger.
Find out more at <a href="http://www.bloggingtips.com/books">www.bloggingtips.com/books/</a></p>
]]></description>
			<content:encoded><![CDATA[<p>CSS stands for Cascading Style Sheets. Its job is to control the presentation of a web page document, written in (x)HTML. The idea is that your web document, written in (x)HTML, contains the content and structure of your page, and then you apply the CSS to give the page colour and layout, keeping content separate from design. To understand more on this way of working I recommend reading <a href="http://reference.sitepoint.com/css/css">SitePoint&#8217;s &#8211; What is CSS?</a>.</p>
<p>There are 3 ways in which we can apply CSS styles to a web page.</p>
<ol>
<li>In an external style sheet</li>
<li>In an internal style sheet</li>
<li>Using inline styles</li>
</ol>
<h3>CSS Rulesets</h3>
<p>For an internal or external stylesheet, the CSS is made up of rulesets, which contain the selector (usually an (x)HTML tag, id or class), then the properties and their values to apply to that selector, eg.</p>
<pre class="brush: css;">selector1 {
    property1: value;
    property2: value;
}
selector2 {
    property3: value;
    property1: value;
}</pre>
<p>We&#8217;ll be dealing more with CSS and the various properties available over the forthcoming weeks.</p>
<h3>External Style Sheets</h3>
<p>To link to an external style sheet you can either use the link tag or import the style sheet in. With some versions of Internet Explorer still being a bit buggy with the @import method, it&#8217;s usually a good idea to stick with the link tag.</p>
<h4>The Link Tag</h4>
<p>To use the link tag you insert the following code into the head section of your (x)HTML document (ie. between the &lt;head&gt;&#8230;&lt;/head&gt; tags).</p>
<p><code>&lt;link type=&quot;text/css&quot; href=&quot;/css/style.css&quot; rel=&quot;stylesheet&quot; /&gt;</code></p>
<p>Here the attribute <strong>href</strong> contains the path to the style sheet. This can be relative to the page eg. ../css/style.css or relative to the root of the site eg. /css/style.css. The <strong>rel</strong> then usually contains the value of &#8217;stylesheet&#8217; to tell the document that the linked file is a style sheet. You can also specify a value of &#8216;alternate&#8217; to specify an alternative style sheet. This won&#8217;t be loaded by default but the user can switch to it via their browser settings. However, we&#8217;ll get onto alternate style sheets another time!</p>
<p>The link tag is also used for linking other files so be sure to have a correct rel attribute in there. The <strong>type</strong> attribute tells the browser what type of content the file contains, which for style sheets is plain text css code. Finally, we have an optional attribute of <strong>media</strong> which lets you tell the browser how and when the style sheet should be used. Examples of media values is all (default), screen (for colour computer screens), handheld (for handheld devices eg. PDA) and print (for print preview and printing a document). If media is omitted then it is set to all by default.</p>
<h4>The @import Method</h4>
<p>To use the @import method we insert the following into the head section of the web document</p>
<p><code>&lt;style type=&quot;text/css&quot;&gt;<br />
@import url(/css/style.css);<br />
&lt;/style&gt;</code></p>
<p>The value of the path inside the brackets of the url should either be relative to the page importing the file or relative to the root, as with the href value of the link tag. Although Internet Explorer can have problems when you specify media types with the @import method, there&#8217;s no problem using this method within an external style sheet, so you could link to an external style sheet using the link tag in the top of a web document, and then in the external style sheet you could use the @import method to include various style sheets. This is ideal for large sites where multiple style sheets are used for easy structure.</p>
<p>The content of an external style sheet will contain rule sets which are made up of selectors and their property value pairs. A typical example could be</p>
<pre class="brush: css;">body {
    background-color: #ffffff;
    color: #000000;
}
h1 {
    color:#ff0000;
}
etc.
</pre>
<p>Only this type of coding should be in a CSS style sheet. No HTML tags (in diamond brackets) or anything else should be there otherwise the style sheet will probably not load correctly.</p>
<h3>The Internal Style Sheet</h3>
<p>The internal style sheet is similar to the external version, in that all of the rules are kept together, however instead of it being applied via a link tag or @import rule, all of the rules are inserted between style tags in the head section of the document. For example</p>
<pre class="brush: css;">&lt;style type=&quot;text/css&gt;
body {
    background-color: #ffffff;
    color: #000000;
}
h1 {
    color: #ff0000;
}
&lt;/style&gt;</pre>
<p>As you can see, this is the same CSS code as that of an external style sheet. Again, the style tag can take a second attribute called &#8216;media&#8217; which can allow you specify different rules for different types of media, similar to the external style sheet method.</p>
<h3>Inline Styles</h3>
<p>Inline styles are CSS styles that are included via the style attribute for any (x)HTML tag. You add in the property value pairs into the attribute to change the style of that particular tag eg.</p>
<pre class="brush: html;">&lt;body style=&quot;background-color: #ffffff; colour: #000000;&quot;&gt;
    &lt;h1 style=&quot;color: #ff0000;&quot;&gt;Hello World!&lt;/h1&gt;
    ....
&lt;/body&gt;</pre>
<h3>Which Way?</h3>
<p>The most suitable method of applying CSS to your web pages is via an external style sheet. It&#8217;s more efficient for updating, and will reduce the amount of bandwidth required on your site, as once the file is loaded for the first page visit, it will be stored in the user&#8217;s browser cache throughout the site.</p>
<p>You can have multiple pages calling this style sheet and if you had, for example, 100+ pages on your site and wanted to change the colour of all the text, you would only need to change the one style sheet file and upload that. All of your text changes colour instantly. Imagine having to change all 100+ pages if they used an internal style sheet or had inline styles?! Even if you use something such as Dreamweaver, which allows you to use a template, and you changed the internal style sheet in that, you would still need to upload all 100+ files.</p>
<hr>Copyright &copy; 2010 <strong><a href="http://www.bloggingtips.com">Blogging Tips</a></strong>. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. Please <a href=http://www.bloggingtips.com/contact/>contact us</a> so we can take legal action immediately.<p><a href="http://www.bloggingtips.com/2008/10/23/understanding-css/">Understanding CSS</a><br /><br />
<a href="http://www.bloggingtips.com/books/"><img src="http://www.bloggingtips.com/ebooks/images/blogging-tips-books.png" alt="Blogging Tips Books"></a><br />
A selection of e-books to help you improve as a blogger.
Find out more at <a href="http://www.bloggingtips.com/books">www.bloggingtips.com/books/</a></p>
<img src="http://www.bloggingtips.com/?ak_action=api_record_view&id=3651&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.bloggingtips.com/2008/10/23/understanding-css/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Link Block Hover Effect</title>
		<link>http://www.bloggingtips.com/2008/07/19/link-block-hover-effect/</link>
		<comments>http://www.bloggingtips.com/2008/07/19/link-block-hover-effect/#comments</comments>
		<pubDate>Sat, 19 Jul 2008 21:51:36 +0000</pubDate>
		<dc:creator>John Leschinski</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://www.bloggingtips.com/?p=2051</guid>
		<description><![CDATA[It&#8217;s a fairly common trick used nowadays, a block of text with a title and some other information that acts as a link while the only thing that looks like a link in the block is the title. It doesn&#8217;t require any fancy tricks even, but it&#8217;s probably not the most semantic bit of code. [...]<p><a href="http://www.bloggingtips.com/2008/07/19/link-block-hover-effect/">Link Block Hover Effect</a><br /><br />
<a href="http://www.bloggingtips.com/books/"><img src="http://www.bloggingtips.com/ebooks/images/blogging-tips-books.png" alt="Blogging Tips Books"></a><br />
A selection of e-books to help you improve as a blogger.
Find out more at <a href="http://www.bloggingtips.com/books">www.bloggingtips.com/books/</a></p>
]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s a fairly common trick used nowadays, a block of text with a title and some other information that acts as a link while the only thing that looks like a link in the block is the title. It doesn&#8217;t require any fancy tricks even, but it&#8217;s probably not the most semantic bit of code. </p>
<p>Check out the <a href="http://www.bloggingtips.com/wp-content/uploads/2008/07/blocklink.html">demo here.</a></p>
<p>The key is simply wrapping the entire block in the link, and then styling the rest of the content to not look like a link. </p>
<blockquote><p>&lt;li&gt;<br />
&lt;a href=&quot;http://www.bloggingtips.com/&quot;  &gt;Reduce your code.<br />
&lt;span&gt;12 Jul 2008&lt;/span&gt;</p>
<p>&lt;p&gt;Complex designs are quite often a mess of div’s and span’s, it’s not surprising some people are sticking to tables, but unless they have a time machine tables are not the answer, remember it’s CSS or die!&lt;/p&gt; </p>
<p>&lt;/a&gt;</p>
<p>&lt;/li&gt;</p></blockquote>
<p>You can then style the span and the paragraph elements.</p>
<pre class="brush: css;">
.h-links ul {
list-style-type: none;
width:450px;
margin:0; padding:0;
}

.h-links li {
border-bottom:1px dotted #777;
}

.h-links span{
font-size:0.75em;
color:#777;
font-weight:normal;
}

.h-links p{
margin:5px 0 0 0; padding:0;
color:#000;
font-weight:normal;
}

.h-links li a {
color: #CC0033;
text-decoration: none;
font-weight:600;
display:block;
padding: 15px 15px 15px 10px;
}

.h-links li:hover{
background: #eee;
}
</pre>
<p>When you hover over the block, it will highlight and you&#8217;ll be able to click anywhere in the block.<br />
Grab the full code example and play around with it yourself.</p>
<hr>Copyright &copy; 2010 <strong><a href="http://www.bloggingtips.com">Blogging Tips</a></strong>. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. Please <a href=http://www.bloggingtips.com/contact/>contact us</a> so we can take legal action immediately.<p><a href="http://www.bloggingtips.com/2008/07/19/link-block-hover-effect/">Link Block Hover Effect</a><br /><br />
<a href="http://www.bloggingtips.com/books/"><img src="http://www.bloggingtips.com/ebooks/images/blogging-tips-books.png" alt="Blogging Tips Books"></a><br />
A selection of e-books to help you improve as a blogger.
Find out more at <a href="http://www.bloggingtips.com/books">www.bloggingtips.com/books/</a></p>
<img src="http://www.bloggingtips.com/?ak_action=api_record_view&id=2051&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.bloggingtips.com/2008/07/19/link-block-hover-effect/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Use CSS to Style Link Types.</title>
		<link>http://www.bloggingtips.com/2008/07/05/use-css-to-style-links/</link>
		<comments>http://www.bloggingtips.com/2008/07/05/use-css-to-style-links/#comments</comments>
		<pubDate>Sat, 05 Jul 2008 20:34:43 +0000</pubDate>
		<dc:creator>John Leschinski</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://www.bloggingtips.com/?p=2008</guid>
		<description><![CDATA[Ever wanted to style your links to represent the type of content it links too without having to add a class to each link? Well I&#8217;m here again to save the day with a no brainier solution. This is quick and simple so I&#8217;ll get right too it.
Say you want to have all links to [...]<p><a href="http://www.bloggingtips.com/2008/07/05/use-css-to-style-links/">Use CSS to Style Link Types.</a><br /><br />
<a href="http://www.bloggingtips.com/books/"><img src="http://www.bloggingtips.com/ebooks/images/blogging-tips-books.png" alt="Blogging Tips Books"></a><br />
A selection of e-books to help you improve as a blogger.
Find out more at <a href="http://www.bloggingtips.com/books">www.bloggingtips.com/books/</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Ever wanted to style your links to represent the type of content it links too without having to add a class to each link? Well I&#8217;m here again to save the day with a no brainier solution. This is quick and simple so I&#8217;ll get right too it.</p>
<p>Say you want to have all links to PDF&#8217;s have a PDF icon next to it, letting users know they are about to have their browser stall for a few seconds as the file loads. Well all you need to do is add the following to your CSS.<br />
<code><br />
a[href$=&quot;.pdf&quot;]<br />
{<br />
background: url(pdf.png) no-repeat right top;<br />
padding-right: 20px;<br />
}<br /></code></p>
<p>Of course you will need to make some changes to specify the location and name of your image on your server, and possibly adjust the padding so the image sits right, but this is it. <a href="http://www.bloggingtips.com/wp-content/uploads/2008/07/links.html">Check it out working here.</a> It uses the sub string matching attribute selector, and this is how it breaks down.</p>
<p><code>X[YZ=&quot;B&quot;]</code></p>
<p><code>X</code> = the type of selector you want to use. In this example we used the a selector, used for links.</p>
<p><code>Y</code> = the name of the element that will contain the element you want to identify. Here we used href which specifies the location the link is pointing too. </p>
<p><code>Z</code> = can be $ for identifying elements at the end of the string, like file extensions in this example. It can also be a ^ which is used to identify elements at the beginning of the string, like http://feed.</p>
<p><code>B</code> =  the element you are looking for. In this case it was the .PDF extension. </p>
<p>So the following <code>p[title$="bar"] { background-color : lime }</code> would search out any P tag with titles containing bar at the end and turn its background lime green. <a href="http://www.w3.org/Style/CSS/Test/CSS3/Selectors/current/html/tests/css3-modsel-10.html">See it in action here.</a></p>
<p>Let&#8217;s try it one more time, you can <a href="http://www.bloggingtips.com/wp-content/uploads/2008/07/links.html">see these examples</a> in action, with some others thrown in to get you started. Say you want to style links to feeds. If your feeds are like this <code>http://feeds.feedburner.com/blogging-tips</code> then you will want to specify that you want to find, at the beginning of links, <code>http://feeds.</code> and to have it styled appropriately. Like so.<br />
<code><br />
a[href^="http://feeds."]<br />
{<br />
background: url(rss.png) no-repeat right top;<br />
padding-right: 20px;<br />
}</code></p>
<p>It might seem a bit complicated, but play around with the examples and it should come to you quickly. Any questions be sure to ask them in the comments. </p>
<hr>Copyright &copy; 2010 <strong><a href="http://www.bloggingtips.com">Blogging Tips</a></strong>. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. Please <a href=http://www.bloggingtips.com/contact/>contact us</a> so we can take legal action immediately.<p><a href="http://www.bloggingtips.com/2008/07/05/use-css-to-style-links/">Use CSS to Style Link Types.</a><br /><br />
<a href="http://www.bloggingtips.com/books/"><img src="http://www.bloggingtips.com/ebooks/images/blogging-tips-books.png" alt="Blogging Tips Books"></a><br />
A selection of e-books to help you improve as a blogger.
Find out more at <a href="http://www.bloggingtips.com/books">www.bloggingtips.com/books/</a></p>
<img src="http://www.bloggingtips.com/?ak_action=api_record_view&id=2008&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.bloggingtips.com/2008/07/05/use-css-to-style-links/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Fancy Forms</title>
		<link>http://www.bloggingtips.com/2008/06/28/fancy-forms/</link>
		<comments>http://www.bloggingtips.com/2008/06/28/fancy-forms/#comments</comments>
		<pubDate>Sat, 28 Jun 2008 20:00:32 +0000</pubDate>
		<dc:creator>John Leschinski</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://www.bloggingtips.com/?p=1934</guid>
		<description><![CDATA[<img align='right' src="http://www.bloggingtips.com/wp-content/uploads/2008/06/demo-300x150.jpg" alt="Forms Demo" />Forms can be a bit of a pain to style, in the old days tables were the method of choice to align everything just right, but this is the future; CSS OR DIE! P.Diddy will come to your home and kill you if you use tables for presentational markup. So in order to prevent a Diddy disaster here is some helpful information, I accept thanks for saving your lives in cash and gifts off my Amazon wish list.<p><a href="http://www.bloggingtips.com/2008/06/28/fancy-forms/">Fancy Forms</a><br /><br />
<a href="http://www.bloggingtips.com/books/"><img src="http://www.bloggingtips.com/ebooks/images/blogging-tips-books.png" alt="Blogging Tips Books"></a><br />
A selection of e-books to help you improve as a blogger.
Find out more at <a href="http://www.bloggingtips.com/books">www.bloggingtips.com/books/</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Forms can be a bit of a pain to style, in the old days tables were the method of choice to align everything just right, but this is the future; CSS OR DIE! P.Diddy will come to your home and kill you if you use tables for presentational markup. So in order to prevent a Diddy disaster here is some helpful information, I accept thanks for saving your lives in cash and gifts off my Amazon wish list.</p>
<p><img align='left' src="http://www.bloggingtips.com/wp-content/uploads/2008/06/demo-300x150.jpg" alt="Forms Demo" />Forms have three main components. The label, inputs, and the button. Labels are the semantic way to describe what the input is for. Inputs are the fields where you enter the information you are looking to collect from the form. And finally the buttons are, &#8230;wait for it&#8230;, the buttons; like &#8220;submit&#8221; or &#8220;clear&#8221;.</p>
<p>Here is a break down of some code for a quick form. </p>
<p><strong>The HTML</strong><br />
This is a basic form, for the most part you can see where to go from here to expand upon the form. You have labels, forms, and a button. </p>
<pre class="brush: html;">
&lt;div class=&quot;newsletter&quot;&gt;

&lt;h3&gt;Newsletter&lt;/h3&gt;
&lt;p&gt;Sign up for our awesome newsletter!&lt;/p&gt;

&lt;form action=&quot;&quot; method=&quot;post&quot;&gt;

&lt;label for=&quot;name&quot;&gt;Name:&lt;/label&gt;
&lt;input type=&quot;text&quot; name=&quot;name&quot; id=&quot;name&quot;/&gt;

&lt;label for=&quot;email&quot;&gt;Email:&lt;/label&gt;
&lt;input type=&quot;text&quot; name=&quot;email&quot; id=&quot;email&quot;/&gt;

&lt;button type=&quot;submit&quot;&gt;Sign-up&lt;/button&gt;

&lt;/form&gt;

&lt;/div&gt;
</pre>
<p><strong>The CSS</strong><br />
And this is the CSS to style that HTML snippet. </p>
<pre class="brush: css;">
.newsletter {
font-size:0.75em;
text-align:left;
width:450px;
padding:10px;
margin:0 auto;
border:1px solid #CC0033;
}

label{
display:block;
text-align:right;
width:90px;
padding-top:5px;
margin-right: 10px;
float:left;
}

input {
float:left;
font-size:12px;
padding:5px;
width:240px;
margin:2px 0 20px 10px;
border:1px solid #CC0033;
}

button {
background:#CC0033;
border:1px solid #CC0033;
color:#fff;
font-size:1.1em;
padding:5px;
margin-left:110px;
text-align:center;
font-weight:bold;
width:150px;
clear:both;
}
</pre>
<h3>Fancy it up!</h3>
<p>You can add to it further by placing content in the fields by setting a value for the field. </p>
<pre class="brush: html;">
&lt;input type=&quot;text&quot; name=&quot;email&quot; id=&quot;email&quot;   value=&quot;*Top Secret Hint!*&quot;    /&gt;
</pre>
<p>To get even fancier you can make it so that the field clears the data when someone clicks in it to enter their own information. </p>
<pre class="brush: html;">
&lt;input type=&quot;text&quot; name=&quot;email&quot; id=&quot;email&quot; value=&quot;*Top Secret Hint!*&quot;       onfocus=&quot;this.value=''; this.onfocus=null;&quot;        /&gt;
</pre>
<p>If you have Google toolbar with auto fill on you may notice fields like email and name highlighted in yellow, this may not be desirable for a variety of reasons, maybe your form text is in white, but it&#8217;s easy to override. In the input selector in your CSS just add !important to the background value, like so.</p>
<pre class="brush: css;">
input {
float:left;
font-size:12px;
padding:5px;
width:240px;
margin:2px 0 20px 10px;
border:1px solid #CC0033;

background-color: white ! important

}
</pre>
<p>You can see the whole thing <a href="http://www.bloggingtips.com/wp-content/uploads/2008/06/demo.html">in action.</a> But what do you do once you have your fancy pants form? Well if you are creating a mailing list like in the example you can sign up for a service like Campaign Monitor to handle the back end and the database. For a one off thing, like a request for proposal form use <a href="http://www.webformfactory.com/">Web Form Factory</a>. You load the file into it, select how you want it to work, and it will output the information you need.</p>
<p><strong>VOILA!</strong></p>
<hr>Copyright &copy; 2010 <strong><a href="http://www.bloggingtips.com">Blogging Tips</a></strong>. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. Please <a href=http://www.bloggingtips.com/contact/>contact us</a> so we can take legal action immediately.<p><a href="http://www.bloggingtips.com/2008/06/28/fancy-forms/">Fancy Forms</a><br /><br />
<a href="http://www.bloggingtips.com/books/"><img src="http://www.bloggingtips.com/ebooks/images/blogging-tips-books.png" alt="Blogging Tips Books"></a><br />
A selection of e-books to help you improve as a blogger.
Find out more at <a href="http://www.bloggingtips.com/books">www.bloggingtips.com/books/</a></p>
<img src="http://www.bloggingtips.com/?ak_action=api_record_view&id=1934&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.bloggingtips.com/2008/06/28/fancy-forms/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Columns dropping off</title>
		<link>http://www.bloggingtips.com/2008/06/21/columns-dropping-off/</link>
		<comments>http://www.bloggingtips.com/2008/06/21/columns-dropping-off/#comments</comments>
		<pubDate>Sat, 21 Jun 2008 20:12:35 +0000</pubDate>
		<dc:creator>John Leschinski</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://www.bloggingtips.com/?p=1900</guid>
		<description><![CDATA[<a href="http://www.bloggingtips.com/2008/06/21/columns-dropping-off"> <img src="http://www.bloggingtips.com/wp-content/uploads/2008/06/new-3-300x90.jpg" align="left"/></a>

I've talked about <a href="http://www.bloggingtips.com/2008/05/17/design-grid/" title="Design Grid">using grids</a> in designing websites previously, aligning your elements to a formula to create consistency and harmony. This isn't hard to integrate into your design process, but issues can pop up in putting the layout to code; one such problem is columns dropping off. <p><a href="http://www.bloggingtips.com/2008/06/21/columns-dropping-off/">Columns dropping off</a><br /><br />
<a href="http://www.bloggingtips.com/books/"><img src="http://www.bloggingtips.com/ebooks/images/blogging-tips-books.png" alt="Blogging Tips Books"></a><br />
A selection of e-books to help you improve as a blogger.
Find out more at <a href="http://www.bloggingtips.com/books">www.bloggingtips.com/books/</a></p>
]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve talked about <a href="http://www.bloggingtips.com/2008/05/17/design-grid/" title="Design Grid">using grids</a> in designing websites previously, aligning your elements to a formula to create consistency and harmony. It isn&#8217;t hard to integrate into your design process, but issues can pop up in putting the layout to code; one such problem is columns dropping off. </p>
<p><a href="http://www.bloggingtips.com/wp-content/uploads/2008/06/new-2.jpg"><img src="http://www.bloggingtips.com/wp-content/uploads/2008/06/new-2-300x161.jpg" align="left"/></a></p>
<p>As seen in this example image the issue is that the margin <em>(in red)</em> of the object <em>(in yellow)</em> extends past the main containers boundary <em>(in black)</em>. There are two solutions to this problem, the first and the most obvious is to apply a special class to the last column. This is what I have personally used in the past for what its worth.</p>
<p>In a four column layout I will name the class col1 and use it for the first three columns, the fourth and last I will call col4. In my style sheet I set the width of all the columns to 200px and a right margin of 10px, but below that for col4 I rescind that order.</p>
<p>CSS</p>
<pre class="brush: css;">
.col1, .col4{
width:200px;
margin-right:10px;
}

.col4 {
margin-right:0px;
}
</pre>
<p>HTML</p>
<pre class="brush: html;">
&lt;div class=&quot;col1&quot;&gt;Clinical Depression&lt;/div&gt;   

&lt;div class=&quot;col1&quot;&gt;Government of Canada&lt;/div&gt;   

&lt;div class=&quot;col1&quot;&gt;deviantART&lt;/div&gt; 

&lt;div class=&quot;col4&quot;&gt;NortheastEnder&lt;/div&gt;
</pre>
<p><a href="http://www.bloggingtips.com/wp-content/uploads/2008/06/new-3.jpg"><img src="http://www.bloggingtips.com/wp-content/uploads/2008/06/new-3-300x90.jpg" align="left"/></a><br />
The other method is probably the better solution, and the easiest to maintain, esspecialy if you have a dynamic list of items. First you switch up the margin to the left side of the columns, then you give the group a negative margin. You can wrap it in a div or use an unordered list to accomplish this. But the result is the left most margin is cancelled out.</p>
<p>CSS</p>
<pre class="brush: css;">
.work{
width:950px;
margin-left:-10px;
} 

.col1{
float:left;
margin-left:10px;
width:200px;
} 
</pre>
<p>HTML</p>
<pre class="brush: html;">
&lt;div class=&quot;work&gt;   

&lt;div class=&quot;col1&quot;&gt;Clinical Depression&lt;/div&gt;   

&lt;div class=&quot;col1&quot;&gt;Government of Canada&lt;/div&gt;   

&lt;div class=&quot;col1&quot;&gt;deviantART&lt;/div&gt; 

&lt;div class=&quot;col1&quot;&gt;NortheastEnder&lt;/div&gt;

&lt;/div&gt; 
</pre>
<p>Your mileage may vary depending with your settings, but these techniques never fail me.</p>
<hr>Copyright &copy; 2010 <strong><a href="http://www.bloggingtips.com">Blogging Tips</a></strong>. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. Please <a href=http://www.bloggingtips.com/contact/>contact us</a> so we can take legal action immediately.<p><a href="http://www.bloggingtips.com/2008/06/21/columns-dropping-off/">Columns dropping off</a><br /><br />
<a href="http://www.bloggingtips.com/books/"><img src="http://www.bloggingtips.com/ebooks/images/blogging-tips-books.png" alt="Blogging Tips Books"></a><br />
A selection of e-books to help you improve as a blogger.
Find out more at <a href="http://www.bloggingtips.com/books">www.bloggingtips.com/books/</a></p>
<img src="http://www.bloggingtips.com/?ak_action=api_record_view&id=1900&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.bloggingtips.com/2008/06/21/columns-dropping-off/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
