<?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"
	>

<channel>
	<title>thinkwithstyle</title>
	<atom:link href="http://thinkwithstyle.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://thinkwithstyle.com</link>
	<description>About css, xhtml and me</description>
	<pubDate>Wed, 20 Aug 2008 08:12:28 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
	<language>en</language>
			<item>
		<title>css3 selectors test</title>
		<link>http://thinkwithstyle.com/2008/06/25/css3-selectors-test/</link>
		<comments>http://thinkwithstyle.com/2008/06/25/css3-selectors-test/#comments</comments>
		<pubDate>Wed, 25 Jun 2008 11:52:50 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
		
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://thinkwithstyle.com/?p=3</guid>
		<description><![CDATA[CSS3 selectors tests. More than half of the following selectors don&#8217;t work in Firefox 2.0 AND 3.0 (yes, Firefox 3.0 still hasn&#8217;t good support for CSS3), Opera 9.01 and IE7. All of them work fine in Opera 9.5 and Safari 3.0 (Win). However, I prepared them only up to #15, the rest has to wait [...]]]></description>
			<content:encoded><![CDATA[<p>CSS3 selectors tests. More than half of the following selectors don&#8217;t work in Firefox 2.0 AND 3.0 (yes, Firefox 3.0 still hasn&#8217;t good support for CSS3), Opera 9.01 and IE7. All of them work fine in Opera 9.5 and Safari 3.0 (Win). <del datetime="2008-06-19T12:39:36+00:00">However, I prepared them only up to #15, the rest has to wait a couple of days. </del> <span id="more-3"></span></p>
<ul id="css3selectors">
<li>
<h4>Attribute selectors</h4>
<ul>
<li>
<dl>
<dt>E[foo^="bar"]</dt>
<dd>an E element whose “foo” attribute value begins exactly with the string “bar”. </dd>
</dl>
<p><a onclick="toggle_info('selectdiv1');return false;" href="#selectdiv1">Example</a><code> #selectdiv1 p[class^="bar"] {color:red}</code></p>
<div id="selectdiv1" class="info">
<p class="barstring">p.barstring - This paragraph should be colored in red, because it’s class attribute starts with ‘bar’.</p>
<p class="stringbarstring">p.stringbarstring - This paragraph should be unstyled, although it’s class contains the word ‘bar’, but it does not start with it.</p>
</div>
</li>
<li>
<dl>
<dt>E[foo*="bar"]</dt>
<dd>an E element whose “foo” attribute value contains the substring “bar”. </dd>
</dl>
<p><a onclick="toggle_info('selectdiv2');return false;" href="#selectdiv2">Example</a> <code>#selectdiv2 p[class*="bar"] {color:red}</code></p>
<div id="selectdiv2" class="info">
<p class="barstring">p.barstring- This paragraph should be colored in red, because it’s class attribute contains ‘bar’.</p>
<p class="stringbarstring"> p.stringbarstring-This paragraph should be also colored in red, because it’s class attribute contains ‘bar’.</p>
<p class="string">p.string - This paragraph should be unstyled</p>
</div>
</li>
<li>
<dl>
<dt>E[foo$="bar"]</dt>
<dd>an E element whose “foo” attribute value ends exactly with the string “bar”. </dd>
</dl>
<p><a onclick="toggle_info('selectdiv3');return false;" href="#selectdiv3">Example</a> <code>#selectdiv3 p[class$="bar"] {color:red}</code></p>
<div id="selectdiv3" class="info">
<p class="stringbar">p.stringbar - This paragraph should be also colored in red, because it’s class ends with ‘bar’.</p>
<p class="barstring">p.barstring- This paragraph should be unstyled.</p>
<p class="string">p.string - This paragraph should be unstyled</p>
</div>
</li>
</ul>
</li>
<li>
<h4>Pseudo-classes:</h4>
<ul>
<li>
<dl>
<dt>E:root</dt>
<dd>an E element, root of the document. </dd>
</dl>
<p><a onclick="toggle_info('selectdiv4');return false;" href="#selectdiv4">Example</a> <code>html:root #selectdiv4 p:first-child{color:red}</code></p>
<div id="selectdiv4" class="info">
<p>GOTCHA! In html the root element is &lt;html&gt; itself. To show this selector in action, I had to declare html:root #selectdiv4 p:first-child{color:red}. And this paragraph should be red. Not in IE7,  it doesn’t do it.</p>
<p>This paragraph is unstyled, it is black (or grey, whatever).</p>
</div>
</li>
<li>
<dl>
<dt>E:nth-child(n)</dt>
<dd>an E element, the n-th child of its parent. </dd>
</dl>
<p><a onclick="toggle_info('selectdiv5');return false;" href="#selectdiv5">Example</a> <code>#selectdiv5 p:nth-child(2n){color:green} #selectdiv5 p:nth-child(2n+1){color:red}</code></p>
<div id="selectdiv5" class="info">
<p>This paragraph should be red.</p>
<p>This paragraph should be green.</p>
<p>This paragraph should be red</p>
<p>This paragraph should be green.</p>
<p>This paragraph should be red.</p>
<p>This paragraph should be green.</p>
<p>This paragraph should be red.</p>
<p>This paragraph should be green.</p>
<p>This paragraph should be red.  Not for IE7 and Firefox 2.</p>
</div>
</li>
<li>
<dl>
<dt>E:nth-last-child(n)</dt>
<dd>an E element, the n-th child of its parent, counting from the last one. </dd>
</dl>
<p><a onclick="toggle_info('selectdiv6');return false;" href="#selectdiv6">Example</a> <code>#selectdiv6 p:nth-last-child(2n){color:green} #selectdiv6 p:nth-last-child(2n+1){color:red}</code></p>
<div id="selectdiv6" class="info">
<p>This paragraph should be red.</p>
<p>This paragraph should be green.</p>
<p>This paragraph should be red</p>
<p>This paragraph should be green.</p>
<p>This paragraph should be red.</p>
<p>This paragraph should be green.</p>
<p>This paragraph should be red.</p>
<p>This paragraph should be green.</p>
<p>This paragraph should be red. Not for IE7 and Firefox 2</p>
</div>
</li>
<li>
<dl>
<dt>E:nth-of-type(n)</dt>
<dd>an E element, the n-th sibling of its type. </dd>
</dl>
<p><a onclick="toggle_info('selectdiv7');return false;" href="#selectdiv7">Example</a> <code>#selectdiv7 p:nth-of-type(3) {color:red} #selectdiv7 p:nth-of-type(2n+1) {font-weight:bold}</code></p>
<div id="selectdiv7" class="info">
<p>This paragraph should be bold.</p>
<p>This paragraph should be unstyled.</p>
<div>This is a div and should not be affected by the rule, because it’s not a paragraph.</div>
<p>This paragraph should be red and bold.</p>
<p>This paragraph should be unstyled.</p>
</div>
</li>
<li>
<dl>
<dt>E:nth-last-of-type(n)</dt>
<dd>an E element, the n-th sibling of its type, counting from the last one. </dd>
</dl>
<p><a onclick="toggle_info('selectdiv8');return false;" href="#selectdiv8">Example</a> <code>#selectdiv8 p:nth-last-of-type(1) {color:red} #selectdiv8 p:nth-last-of-type(3) {font-weight:bold}</code></p>
<div id="selectdiv8" class="info">
<p>This paragraph should be unstyled.</p>
<p>This paragraph should be bold.</p>
<div>This is a div and should not be affected by the rule.</div>
<p>This paragraph should be unstyled.</p>
<p>This paragraph should be red.</p>
</div>
</li>
<li>
<dl>
<dt>E:last-child</dt>
<dd>an E element, last child of its parent</dd>
</dl>
<p><a onclick="toggle_info('selectdiv9');return false;" href="#selectdiv9">Example</a> <code>#selectdiv9 p:last-child {color:red}</code></p>
<div id="selectdiv9" class="info">
<p>This paragraph should be unstyled.</p>
<p>This paragraph should be unstyled.</p>
<p>This paragraph should be unstyled.</p>
<p>This paragraph should be unstyled.</p>
<p>This paragraph should be unstyled.</p>
<p>This paragraph should be red, because it’s the last child of it’s type.</p>
</div>
</li>
<li>
<dl>
<dt>E:first-of-type</dt>
<dd>an E element, first sibling of its type</dd>
</dl>
<p><a onclick="toggle_info('selectdiv10');return false;" href="#selectdiv10">Example</a> <code>#selectdiv10 p:first-of-type {color:red}</code></p>
<div id="selectdiv10" class="info">
<div>This is a div and should not be affected by the rule, because it’s not a paragraph.</div>
<p>This paragraph should be red.</p>
<p>This paragraph should be unstyled.</p>
<p>This paragraph should be unstyled.</p>
<p>This paragraph should be unstyled.</p>
</div>
</li>
<li>
<dl>
<dt>E:last-of-type</dt>
<dd>an E element, last sibling of its type</dd>
</dl>
<p><a onclick="toggle_info('selectdiv11');return false;" href="#selectdiv11">Example</a> <code>#selectdiv11 p:last-of-type {color:red}</code></p>
<div id="selectdiv11" class="info">
<p>This paragraph should be unstyled.</p>
<p>This paragraph should be unstyled.</p>
<p>This paragraph should be unstyled.</p>
<p>This paragraph should be red.</p>
<div>This is a div and should not be affected by the rule, because it’s not a paragraph.</div>
</div>
</li>
<li>
<dl>
<dt>E:only-child</dt>
<dd>an E element, only child of its parent</dd>
</dl>
<p><a onclick="toggle_info('selectdiv12');return false;" href="#selectdiv12">Example 1</a> <code>#selectdiv12 :only-child {color:red}</code><a onclick="toggle_info('selectdiv121');return false;" href="#selectdiv121">Example 2</a> <code>#selectdiv121 :only-child {color:red}</code></p>
<div id="selectdiv12" class="info">
<p>This paragraph should be red, because is the only child of the outer div.</p>
</div>
<div id="selectdiv121" class="info">
<p>This paragraph should be unstyled, because there are more children of the outer div.</p>
<div>This is a div</div>
</div>
</li>
<li>
<dl>
<dt>E:only-of-type</dt>
<dd>an E element, only sibling of its type</dd>
</dl>
<p><a onclick="toggle_info('selectdiv13');return false;" href="#selectdiv13">Example 1</a> <code>#selectdiv13 p:only-of-type {color:red}</code><a onclick="toggle_info('selectdiv131');return false;" href="#selectdiv131">Example 2</a> <code>#selectdiv131 :only-of-type {color:red}</code></p>
<div id="selectdiv13" class="info">
<p>This paragraph should be red because it’s the only child of it’s type.</p>
<div>This is a div.</div>
</div>
<div id="selectdiv131" class="info">
<p>This paragraph should be unstyled, because there are several children of it’s type in the outer div.</p>
<p>This paragraph should be unstyled, because there are several children of it’s type in the outer div.</p>
<div>But this div should be red, because it’s teh only child of it’s type.</div>
</div>
</li>
<li>
<dl>
<dt>E:empty</dt>
<dd>an E element that has no children (including text nodes)</dd>
</dl>
<p><a onclick="toggle_info('selectdiv14');return false;" href="#selectdiv14">Example</a><code>#selectdiv14 p:empty {padding:50px 0}</code></p>
<div id="selectdiv14" class="info">
<p>This paragraph should be unstyled, because it’s not empty - text nodes count, including whitespaces.</p>
<p><!-- this is a comment, and therefore the p is considered empty --></p>
<p>If above is a huge blank space, it means that the declaration works. Above is an empty paragraph containing a comment and nothing else.</p>
</div>
</li>
<li>
<dl>
<dt>E:target</dt>
<dd>an E element being the target of the referring URI</dd>
</dl>
<p><a onclick="toggle_info('selectdiv15');return false;" href="#selectdiv15">Example</a> <code>#selectdiv15 :target {background:#fc3}</code></p>
<div id="selectdiv15" class="info">
<ul>
<li><a href="#div1">This is the link to the target div 1</a></li>
<li><a href="#div2">This is the link to the target div 2</a></li>
<li><a href="#div3">This is the link to the target div 3</a></li>
</ul>
<div id="div1">This is the target div 1</div>
<div id="div2">This is the target div 2</div>
<div id="div3">This is the target div 3</div>
</div>
</li>
<li>
<dl>
<dt>E:enabled, E:disabled</dt>
<dd> a user interface element E which is enabled or disabled</dd>
</dl>
<p><a onclick="toggle_info('selectdiv16');return false;" href="#selectdiv16">Example</a> <code>#selectdiv16 :enabled {border:1px solid red} #selectdiv16 :disabled {border:1px solid blue}</code></p>
<div id="selectdiv16" class="info">
<p>
<input type="text" /> An input which should have a red border Inputs are enabled by default.</p>
<p>
<input disabled="disabled" type="text" /> An input with blue border  because it was disabled.</p>
<p>
<select disabled="disabled"><option>Option1 </option></select>
</p>
<p>A select box with blue border  because it was disabled.</p>
</div>
</li>
<li>
<dl>
<dt>E:checked</dt>
<dd>a user interface element E which is checked (for instance a radio-button or checkbox)</dd>
</dl>
<p><a onclick="toggle_info('selectdiv17');return false;" href="#selectdiv17">Example</a> <code>#selectdiv17 input:checked {border:1px solid red}</code></p>
<div id="selectdiv17" class="info">
<p>
<input checked="checked" type="radio" /> This is a radiobutton which should have a red border, because it has checked=”checked”.</p>
<p><input type="checkbox" /> This is a checkbox and whould have red border only when it’s checked</p>
<p><input checked="checked" type="text" /> This is a text input and should not have red border even if it has checked=”checked”, because attribute “checked” is not meant for this type of inputs.</p>
</div>
</li>
<li>
<dl>
<dt>E:not(s)</dt>
<dd>an E element that does not match simple selector s</dd>
</dl>
<p><a onclick="toggle_info('selectdiv19');return false;" href="#selectdiv19">Example</a> <code>#selectdiv19 :not(.some_class) {color:red}</code></p>
<div id="selectdiv19" class="info">
<p>This paragraph should be red, because it does not have class=”some_class”</p>
<p class="some_class">This paragraph should be unstyled, bacause it has class=”some_class”.</p>
<p class="some_class">This paragraph should be unstyled, bacause it has class=”some_class”.</p>
<h3>This heading h3 should be red, because it does not have class=”some_class”</h3>
<h3 class="some_class">This heading h3 should be unstyled, because it does have class=”some_class”</h3>
</div>
</li>
</ul>
</li>
<li>
<h4>General sibling combinator:</h4>
<ul>
<li>
<dl>
<dt>E ~ F</dt>
<dd>an F element preceded by an E element</dd>
</dl>
<p><a onclick="toggle_info('selectdiv20');return false;" href="#selectdiv20">Example 1</a> <code>#selectdiv20 h3 ~ p {color:red}</code><br />
 <a onclick="toggle_info('selectdiv201');return false;" href="#selectdiv201">Example 2</a> <code>#selectdiv20 h3.blue ~ p {color:blue}</code></p>
<div id="selectdiv20" class="info">
<p>This paragraph should be unstyled, because no heading h3 comes before it.</p>
<h3>This is a h3 heading</h3>
<p>This paragraph should be red because it is next and adjiacent to a heading h3.</p>
<p>This paragraph should be red because it comes after a heading h3.</p>
<p>This paragraph should be red because it comes after a heading h3</p>
</div>
<div id="selectdiv201" class="info">
<p>This paragraph should be unstyled, because no heading h3 comes before it.</p>
<h3>This is a h3 heading</h3>
<p>This paragraph should be red because it is next and adjiacent to a heading h3.</p>
<p>This paragraph should be red because it comes after a heading h3.</p>
<h3 class="blue">This is a h3 heading class=”blue”</h3>
<p>This paragraph should be blue because it comes after a heading h3.blue</p>
<p>This paragraph should be blue because it comes after a heading h3.blue</p>
</div>
</li>
</ul>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://thinkwithstyle.com/2008/06/25/css3-selectors-test/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
