<?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>Hanfis Weg in die Hölle &#187; css</title>
	<atom:link href="http://blog.spahan.ch/tag/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.spahan.ch</link>
	<description>oder zumindest in deren Nähe</description>
	<lastBuildDate>Sat, 04 Sep 2010 21:36:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>exploring css, inside w3c</title>
		<link>http://blog.spahan.ch/2008/01/exploring-css-inside-w3c/</link>
		<comments>http://blog.spahan.ch/2008/01/exploring-css-inside-w3c/#comments</comments>
		<pubDate>Sat, 05 Jan 2008 10:26:29 +0000</pubDate>
		<dc:creator>hanfi</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[css]]></category>

		<guid isPermaLink="false">http://blog.spahan.ch/2008/01/exploring-css-inside-w3c/</guid>
		<description><![CDATA[I discovered css some years ago. Since then i used it frequently for some of my websites, mainly to customize phpBB forums. The Greck Website is a nice small css-based html page. For the Ghost-projekt I started to look a little bit deeper into css. So I went out and checked the World Wide Web [...]]]></description>
			<content:encoded><![CDATA[<p>I <em>discovered</em> css some years ago. Since then i used it frequently for some of my websites, mainly to customize <a href="http://www.phpbb.com/">phpBB</a> forums. The <a href="http://greck.spahan.ch">Greck Website</a> is a nice small css-based html page.</p>
<p>For the Ghost-projekt I started to look a little bit deeper into css. So I went out and checked the <a href="http://www.w3.org/">World Wide Web Consortium WebSite</a>. While playing around I found <a href="http://sirdarckcat.blogspot.com/2007/11/csk2-and-css-applications.html">this blog entry</a> about css, and got really impressed by those guys and what css can do.</p>
<p>Well, now here i am. Having a lot to play with and even more that I dont understand completly.</p>
<p>For sure, the most interesting part for me right now are the pseudo-elements and -classes. Looks fun to play with.  So I tried this:</p>
<pre><code>
HTML
&lt;body&gt;&lt;div&gt;
&lt;p&gt;first child in this html.&lt;br/&gt;forcing a line break for sake of example.&lt;/p&gt;
&lt;p&gt;next child in this html.&lt;br/&gt;forcing a line break for sake of example.&lt;/p&gt;
&lt;/div&gt;&lt;/body&gt;

CSS
p:first-child { color: red;}
p:first-line {	color: blue;}
</code></pre>
<p>So far so good. You can see the example <a href="http://blog.spahan.ch/wp-content/uploads/2008/01/cssfun.html" title="CSS Fun">here</a>.<br />
Looks right? First Child is red, second black. and the first lines of both are blue. Well&#8230;.<br />
Lets review the css docu on w3c. In special check what <em>type</em> those selectors have.<br />
:first-child is a <em>attribute</em> selector (classes are attributes)<br />
:first-line is a <em>element</em> selector<br />
so whats the precedence for those 2?<br />
checking the <a href="http://www.w3.org/TR/CSS21/cascade.html#specificity">relevant css docus</a> we calculate these values:<br />
p:first-child: a=0, b=0, c=1, d=1<br />
p:first-line: a=0, b=0, c=0, d=2<br />
now check the first the first &lt;p&gt; tag. Shouldn&#8217;t the first-child be more specific and therefore overwrite the first-line?<br />
well, we can go and try force it even more.<br />
lets change the firs-child style selector to<br />
<code>div p:first-child ...</code><br />
this time we have  a specific precedence of a=0, b=0, c=1, d=2<br />
this clearly should outrule the first-line style.</p>
<p>Well, there <strong>is</strong> a way to explain this.<br />
According to the <a href="http://www.w3.org/TR/CSS21/selector.html#pseudo-element-selectors">css specification</a> about the pseudo elements the UA creates a <em>fictional tag sequence</em> by inserting &lt;p:first-line&gt; and its end tag into the tree. <strong>BUT</strong> the UA doesn&#8217;t (mustn&#8217;t ?) write this back into the <em>real</em> Document tree. Therefore, the p:first-child has a p:first-line inside thats <strong>not visible</strong> to the HTML/Javascript/etc.</p>
<p>Why is that worth a blog here?<br />
Well, basicaly we can create a browser state where the DOM-Tree and the <em>css tree</em> are out of sync. This could be used to hide/display things not in the DOM-tree. I don&#8217;t found a way to abuse this so far&#8230;but its still interesting to know that css and DOM see different things.</p>
<p>PS: I am a complete newb in css. I have no idea if my explanation above is correct, nor i see a way to prove it. Any explanation/addition/references are highely welcomed.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.spahan.ch/2008/01/exploring-css-inside-w3c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
