<?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>Ash Searle's Blog &#187; CSS</title>
	<atom:link href="http://hexmen.com/blog/category/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://hexmen.com/blog</link>
	<description>On programming, and other things...</description>
	<lastBuildDate>Mon, 03 Jan 2011 16:21:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Microformats, dark data and CSS &#8211; part&#160;2</title>
		<link>http://hexmen.com/blog/2008/07/microformats-dark-data-and-css-part-2/</link>
		<comments>http://hexmen.com/blog/2008/07/microformats-dark-data-and-css-part-2/#comments</comments>
		<pubDate>Mon, 21 Jul 2008 14:52:01 +0000</pubDate>
		<dc:creator>Ash</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://hexmen.com/blog/?p=53</guid>
		<description><![CDATA[The first part of this article considered over 100 HTML 4 attributes and came to the conclusion class was the only one suitable for storing machine data (i.e. data specifically inserted and intended for machine parsing.) In this second part, I&#8217;ll review several ways to store data in the class attribute, determine the &#8216;best&#8217; method, [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://hexmen.com/blog/2008/07/microformats-dark-data-and-css-part-1/">first part of this article</a> considered over 100 HTML 4 attributes and came to the conclusion <code>class</code> was the only one suitable for storing <em>machine data</em> (i.e. data specifically inserted and intended for machine parsing.)</p>
<p>In this second part, I&#8217;ll review several ways to store data in the class attribute, determine the &#8216;best&#8217; method, and suggest a CSS implementation change that is (<abbr title="in my opinion">IMO</abbr>) both trivial and immensely beneficial.</p>
<p>We start by considering the definition of the class attribute, how it&#8217;s value is interpreted, and what restrictions this this places on us for storing data.</p>
<h3>Isn&#8217;t <code>class</code> object-oriented?</h3>
<p>Some people say <code>class</code> has an object-oriented use as though (X)HTML and CSS are object-oriented languages, with inheritance based on <code>class</code> values.  But that&#8217;s not how things work: inheritance is based on parent/child relationships, with everything else determined by &#8220;<a href="http://www.w3.org/TR/REC-CSS2/cascade.html">the cascade</a>&#8220;.</p>
<p>Let me illustrate with a contact directory example I hope isn&#8217;t too contrived.</p>
<p>Contact phone numbers are styled using common fonts and padding, but with different background-images based on the type of phone number (home, work, fax etc.)  Using a top-level concept class of <code>tel</code>, we <em>&#8220;subclass&#8221;</em> using <code>home</code>, <code>work</code> and <code>fax</code>.</p>
<p>Phone numbers can be output and formatted using multiple classes working together:</p>
<pre><code>&lt;span class="tel home">+1 212 123 1234&lt;span></code></pre>
<p>Because <code>home</code> is such a generic term, we&#8217;d write CSS using a 2-class selector like this:</p>
<pre><code>
.tel { font: ...; padding-left: 16px; background: transparent no-repeat middle left; }
.tel.home { background-image: url(icons/tel-home.gif); }
.tel.work { background-image: url(icons/tel-work.gif); }
.tel.fax { background-image: url(icons/tel-fax.gif); }
</code></pre>
<p>Dropping <code>tel</code> from the mark-up would cause all styling to be lost &#8211; the value <code>home</code> on its own does not encapsulate enough information to determine its position in a class hierarchy.  Later on, I&#8217;ll come back to this and suggest hyphenation as an option that may embody a class relationship more explicitly.</p>
<h3>Unordered <code>class</code> data</h3>
<p>By definition, class is an unordered set of white-space separated values.  The values &#8220;tel home&#8221; and &#8220;home tel&#8221; should be treated the same, with the CSS selector &#8220;.tel.home&#8221; applying with equal specificity to both numbers below.</p>
<pre><code>
&lt;span class="tel home">+1 212 12341 12112&lt;span>
&lt;span class="home tel">+1 212 12341 12112&lt;span>
</code></pre>
<p>We must bear this ordering-independence in mind when storing data in <code>class</code>.  Trying to store multiple bits of data in sequential order cannot work &#8211; e.g. a conference schedule:</p>
<pre><code>
...
&lt;li>&lt;span class="dtstart 9:00 dtend 9:15" title="9am">09:00&lt;/span> - Registration&lt;/li>
&lt;li>&lt;span class="dtstart 9:15 dtend 10:30" title="9:15am">09:15&lt;/span> - Keynote&lt;/li>
&lt;li>&lt;span class="dtstart 10:30 dtend 10:45" title="10:30am">10:30&lt;/span> - Coffee&lt;/li>
&lt;li>&lt;span class="dtstart 10:45 dtend 12:00" title="10:45am">10:45&lt;/span> - Session 1&lt;/li>
&lt;li>&lt;span class="dtstart 13:00 dtend 14:00" title="1pm">13:00&lt;/span> - Session 1&lt;/li>
...
</code></pre>
<p><em>Note: in this example, humans are supposed to infer end-times by looking at the start-time of the following event.  We include machine-data for end-times because &#8220;inference&#8221; is not easy for programmers to implement.<br />
</em></p>
<p>Although the order is clear and correct in the mark-up, browsers, parsers and libraries have no obligation to maintain the order when accessed.  e.g. a &#8220;classes&#8221; method could return an arbitrarily ordered array of classes:</p>
<pre><class>
// fetch the classes for the first item in the schedule:
var classes = $('.dtstart:nth(0)').classes();
// may output: ["9:00", "9:15", "dtend", "dtstart"]
</class></pre>
<p>Without further labouring, the take-home point is: data in class-values cannot rely on ordering.</p>
<h3>The necessity of prefixes</h3>
<p>You may not be 100% certain how your content will be processed or transformed, or what corruption it may suffer; but you can at least <em>attempt</em> to mitigate disaster.</p>
<p>For example: times embedded in machine-data can be arbitrarily precise, from specifying years on their own (&#8220;2008&#8243;), to fully specifying a time-zone and exact second of an event (&#8220;20080721T124032+0100&#8243;)  The longer format is unlikely to cause confusion (to machines), but the shorter variants could easily be mistaken for model numbers.  e.g. the ISSN of periodicals for sale:</p>
<pre><code>
&lt;li>&lt;a href="..." class="issn 02624079 dtstart 20080719" title="New Scientist dated 19th July 2008">New Scientist no. 2665&lt;/a>&lt;/li>
</code></pre>
<p>As we can&#8217;t rely on ordering, we need to join the data-type and the data-value together.  A few approaches have been suggested, including wrapping the value, or concatenating the pieces with an arbitrary separator &#8211; I suggest using a hyphen, which I&#8217;ll justify in a minute:</p>
<pre><code>
&lt;a href="..." class="issn{02624079} dtstart{20080719}">
&lt;a href="..." class="issn#02624079 dtstart#20080719">
&lt;a href="..." class="issn-02624079 dtstart-20080719">
</code></pre>
<h3>The hyphenated-prefix selector <code>[attribute|=prefix]</code></h3>
<p>CSS 2 introduced <a href="http://www.w3.org/TR/REC-CSS2/selector.html#attribute-selectors">several attribute selectors</a>, including one I&#8217;m calling the hypehenated-prefix selector.</p>
<p>The specification admits the primary purpose of this selector is for matching language subcodes; i.e. where CSS rules need only apply to content written in some subset of natural languages:</p>
<pre><class>
[lang|=en] blockquote, [lang|=en] q, blockquote[lang|=en], q[lang|=en] { quotes: '“' ”'; }
[lang|=de] blockquote, [lang|=de] q, blockquote[lang|=de], q[lang|=de] { quotes: '«' '»'; }
</class></pre>
<p>The rules above specify different quote-marks for German and English.  Using the prefix selector means the appropriate rule applies to all English languages, including &#8220;en-GB&#8221; and &#8220;en-US&#8221;, as well as content marked no more specifically than lang=&#8221;en&#8221;.  Similarly, the &#8216;de&#8217; rule applies to all German languages.</p>
<p>However, this selector can just as easily be applied to classes.  We can rewrite the telephone-number example as:</p>
<pre><code>
&lt;span class="tel-work">+1 212 800 1234&lt;span>
&lt;span class="tel-home">+1 212 123 1234&lt;span>
</code></pre>
<pre><code>
[class|=tel] { font: ...; padding-left: 16px; background: transparent no-repeat middle left; }
.tel-home { background-image: url(icons/tel-home.gif); }
.tel-work { background-image: url(icons/tel-work.gif); }
.tel-fax { background-image: url(icons/tel-fax.gif); }
</code></pre>
<h3>Relaxing the hyphenated-prefix rules</h3>
<p>Sadly, the hyphenated-prefix is overly-restricted.  In the following example, only one rule applies:</p>
<pre><code>
[class|=issn] { font-weight: bold }
[class|=dtstart] { background-image: url(bg/microformat.gif); }

&lt;li>&lt;a href="..." class="issn-02624079 dtstart-20080719" title="New Scientist dated 19th July 2008">New Scientist no. 2665&lt;/a>&lt;/li>
</code></pre>
<p>The problem is due to the way <code>[attribute|=prefix]</code> is defined:</p>
<blockquote cite="http://www.w3.org/TR/REC-CSS2/selector.html#attribute-selectors"><p>Match when the element&#8217;s &#8220;att&#8221; attribute value is a hyphen-separated list of &#8220;words&#8221;, beginning with &#8220;val&#8221;. <em>The match always starts at the beginning of the attribute value.</em> This is primarily intended to allow language subcode matches (e.g., the &#8220;lang&#8221; attribute in HTML) as described in RFC 1766 ([RFC1766]).
</p></blockquote>
<p>(Emphasis added.)</p>
<p>If the definition had instead been made to cater for a white space separated set of hyphenated tokens, we&#8217;d be in a much better position for styling and parsing machine-data microformats today.</p>
<h3>[attribute|=prefix] implementations</h3>
<p>(Surprisingly) the big four browsers (including IE7) all support the hyphenation prefix selector.  But, JavaScript library support is lacking, specifically (naming the javascript library I use daily) <a href="http://jquery.com/">jQuery</a> doesn&#8217;t handle the hyphenated-prefix selector, although it&#8217;s a simple patch.</p>
<p>Assuming JavaScript libraries (or microformat parsers) already implement attribute-selectors, it&#8217;s a simple matter to support white space separated hyphenated-prefixes.  The key regular-expression is:</p>
<pre><code>/(^|\s)prefix(-|\s|$)/</code></pre>
<p>Assuming your users know what they&#8217;re doing and are willing to fix their own issues after throwing something stupid at your library, the regular-expression is easily built on executed on the fly:</p>
<pre><code>
new RegExp("(^|\\s)" + prefix + "(-|\\s|$)").test(attribute)
</code></pre>
<p>Or (I think), in <a href="http://www.w3.org/TR/xpath-functions/#func-matches">XPath 2.0</a>:</p>
<pre><code>
//*[matches(@attribute, "(^|\s)prefix(-|\s|$)")]
</code></pre>
<h3>Encoding data</h3>
<p>Quotations and ampersands aside (naturally taken care of by normal (X)HTML encoding rules) there&#8217;s an obvious problem when data-values contain white space.  Fortunately, there&#8217;s also an obvious solution, as several methods exist to encode arbitrary data into continuos strings without any white-space.  In JavaScript, the methods available include <code>escape</code>, <code>encodeURI</code> and <code>encodeURIComponent</code>, and I&#8217;d suggest <code>encodeURI</code> as the best option &#8211; providing a good balance between safely encoding data, without being overly aggressive and creating human-unreadable data.</p>
<h3>Simplicity is the key</h3>
<p>Microformats success depends on its simplicity; using a few attributes and a handful of patterns to invisibly add extra layers of information to existing content.</p>
<p>Hopefully, I haven&#8217;t suggested anything in conflict with existing microformats.  Hyphenated-prefixes should be viewed as an <em>additional tool</em> in your arsenal.  Not as a competing or successor solution.</p>
<p>With a more flexible definition of the that damned attribute selector, I&#8217;m sure the <a href="http://unapi.info/specs/">unAPI</a> folks would have produced an <em>even simpler</em> specification, and the arguments around microformat&#8217;s <a href="http://microformats.org/wiki/datetime-design-pattern">datetime design pattern</a> would have been resolved years ago.</p>
<p>Though I&#8217;m sure it doesn&#8217;t show, I&#8217;ve written and rewritten this article many times, but it doesn&#8217;t get any more complex:</p>
<p><strong>If you want to piggy-back machine-data on existing content, use the class attribute.  Separate data-types from data-values using a hyphen, and encode the data using something equivalent to JavaScript&#8217;s <code>encodeURI</code>.</strong></p>
<p>That&#8217;s all folks</p>
]]></content:encoded>
			<wfw:commentRss>http://hexmen.com/blog/2008/07/microformats-dark-data-and-css-part-2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Microformats, dark data and CSS &#8211; part&#160;1</title>
		<link>http://hexmen.com/blog/2008/07/microformats-dark-data-and-css-part-1/</link>
		<comments>http://hexmen.com/blog/2008/07/microformats-dark-data-and-css-part-1/#comments</comments>
		<pubDate>Tue, 15 Jul 2008 12:53:22 +0000</pubDate>
		<dc:creator>Ash</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://hexmen.com/blog/?p=52</guid>
		<description><![CDATA[There&#8217;s was a bit of kerfuffle when the BBC dropped support for microformats in their program listings. You can&#8217;t argue with their reasons: data for microformats was being read aloud by screen-readers, popping up as tool-tips, and confusing the hell out of their users. The microformats community rallied to solve the issue, but Auntie Beeb [...]]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s was a bit of kerfuffle when the <a href="http://www.bbc.co.uk/blogs/radiolabs/2008/06/removing_microformats_from_bbc.shtml">BBC dropped support for microformats</a> in their program listings.</p>
<p>You can&#8217;t argue with their reasons: data for <a href="http://microformats.org/">microformats</a> was being read aloud by screen-readers, popping up as tool-tips, and confusing the hell out of their users.</p>
<p>The microformats community rallied to solve the issue, but <a href="http://www.bbc.co.uk/blogs/bbcinternet/2008/07/why_the_bbc_removed_microforma.html">Auntie Beeb rejected all their proposals</a>; and due to lack of community support, also back-tracked on their own proposal (inserting <code>data-</code> prefixed values into the <code>class</code> attribute.)</p>
<p>You can&#8217;t blame them for rejecting the microformats community&#8217;s proposals.  This proposal feels particularly torturous:</p>
<pre><code>
&lt;p>
  To be held on
  &lt;span class="dtstart dtend">
    &lt;abbr class="value" title="1998-03-12">
      12 March 1998
    &lt;/abbr>
  &lt;/span>
  from
  &lt;span class="dtstart">
    &lt;abbr class="value" title="08:30">
      8:30am
    &lt;/abbr>
    &lt;abbr class="value" title="-0500">
      EST
    &lt;/abbr>
  &lt;/span>
  until
  &lt;span class="dtend">
    &lt;abbr class="value" title="09:30">
      9:30am
    &lt;/abbr>
    &lt;abbr class="value" title="-0500">
      EST
    &lt;/abbr>
  &lt;/span>
&lt;/p>
</code></pre>
<p>That suggestion seems to be the result of a <a href="http://rbach.priv.at/Microformats/IRC/2008-06-24#T161218">30 minute brain-fart by microformat&#8217;s spiritual leader</a> and, like the BBC, I find it &#8220;complicated&#8221; (I doubt that was the first word that sprang to mind though.)</p>
<p>Let&#8217;s go back to the specs and see what HTML gives us to work with.  Considering over one hundred <a href="http://www.w3.org/TR/REC-html40/index/attributes.html">attributes in HTML 4</a>, only a handful apply to the elements we&#8217;d want to tag (not just <code>&lt;abbr&gt;</code>, but also <code>&lt;span&gt;</code>, <code>&lt;a&gt;</code>, <code>&lt;li&gt;</code> amongst several others.)</p>
<p>The only attributes available to insert microformat data and still pass validation are: <code>class</code>, <code>dir</code>, <code>id</code>, <code>lang</code>, <code>style</code> and <code>title</code>.</p>
<p>We&#8217;ve dismissed all event-handling attributes (<code>on<em>whatever</em></code>) as they&#8217;re supposed to contain script, and we can quickly dismiss a few more attributes now:</p>
<p><code>dir</code> can only contain two values (<code>ltr</code> and <code>rtl</code>.)  </p>
<p><code>id</code> must be unique per page; that&#8217;s a restriction we can&#8217;t work with for microformats.</p>
<p><code>style</code> attributes are supposed to hold CSS properties.  It <em>could</em> be subverted using a <a href="http://www.w3.org/TR/CSS21/syndata.html#vendor-keywords">vendor prefix</a> e.g. <code>style="-mf-dtstart: ..."</code>.  However, you&#8217;d buy yourself a place in hell, and you&#8217;d never get support from the microformats community.</p>
<p>That leaves us with <code>lang</code>, <code>title</code> and <code>class</code>.</p>
<h2>Why <code>lang</code>?</h2>
<p>Good question.</p>
<p>The <code>lang</code> attribute indicates what language the <em>content</em> of an element is held in.  Language codes were defined in <a href="http://www.ietf.org/rfc/rfc1766.txt">RFC 1766</a>, since replaced by <a href="http://www.ietf.org/rfc/rfc3066.txt">RFC 3066</a>, which has itself been replaced by a due of RFCs: <a href="http://www.ietf.org/rfc/rfc4646.txt">4646</a> and <a href="http://www.ietf.org/rfc/rfc4647.txt">4647</a>.</p>
<p>Amongst the long lists of language codes, you can find a few options that <em>should</em> let you embed machine-data without it being read-aloud.  e.g. the language-code <code>zxx</code> indicates there&#8217;s &#8220;no linguistic content&#8221;, so you might think a screen-reader would simply skip the content:</p>
<pre><code>
&lt;p>
  To be held on 12 March 1998
  &lt;span class="dtstart dtend" lang="zxx">1998-03-12&lt;/span>
  from 8:30am EST
  &lt;span class="dtstart" lang="zxx">08:30-0500&lt;/span>
  until 9:30am EST
  &lt;span class="dtend" lang="zxx">09:30-0500&lt;/span>
&lt;/p>
</code></pre>
<p>Sadly, a quick trial using accessibility features on a mac reveals the content it still read aloud.  I suspect the other possible language codes &#8211; <code>art</code> for &#8220;artificial languages&#8221;, and the <code>x-</code> prefix for &#8220;private use&#8221; &#8211; would suffer the same fate.</p>
<p>Also, the content would need hiding from sighted users using a simple CSS rule: <code>[lang|=zxx] { display: none }</code> &#8211; but this would fail under various viewing conditions (e.g. syndicating data via RSS without styles.)</p>
<p>Finally, the whole idea of marking machine-data using the <code>lang</code> attribute may be frowned upon.  RFC 4646 includes this:</p>
<blockquote cite="http://rfc.net/rfc4646.html#s2."><p>Language tags are used to help identify languages, whether spoken, written, signed, or otherwise signaled, for the purpose of communication.  This includes constructed and artificial languages, but excludes languages not intended primarily for human communication, such as programming languages.</p></blockquote>
<p>Looks like the <code>lang</code> attribute&#8217;s a bit of a no-no then.  That leaves us with <code>class</code> and <code>title</code>.</p>
<h2><code>title</code> vs. <code>class</code></h2>
<p>We&#8217;ve already mentioned the accessibility issues with <code>title</code>.  The BBC have done the research and user-testing other people only think about.  Their results show <em>it&#8217;s not just screen-readers</em> that get confused by machine-data in <code>title</code> attributes &#8211; sighted users are baffled too.</p>
<p>Fragmenting one machine-readable value into three doesn&#8217;t solve the problem &#8211; it exacerbates it.  The number of elements with mystical tool-tips increases; while human-friendliness increases for some (dates), it decreases for others (timezones).</p>
<p>The <code>title</code> attribute is meant for humans, no matter how you spin it.</p>
<h2>All hail the mighty <code>class</code></h2>
<p>I must apologize: did I just have a &#8220;<code>title</code> vs. <code>class</code>&#8221; debate without mentioning <code>class</code>?</p>
<p>I guess I did.  <code>title</code> got disqualified, leaving <code>class</code> to win by default.</p>
<p><em>(small side-note: out of all the attributes on the short-list, <code>class</code> is the <strong>only one</strong> defined to contain <code>CDATA</code> &#8211; i.e. general-purpose Character DATA.  Just thought that might be worth a mention.)</em></p>
<p>Having whittled down our options to one winner, we now need to decide how we&#8217;re going to organize our data, and cram it into the <code>class</code> attribute.  We need to take into account the definition of <code>class</code>, and that the attribute-value is treated as an <em>unordered</em> list of <em>white-space separated</em> tokens.</p>
<p>That&#8217;s for part 2, where I also propose tweaking a CSS3 selector to change it from a single niche application to become a general purpose tool in a web-designers arsenal.</p>
]]></content:encoded>
			<wfw:commentRss>http://hexmen.com/blog/2008/07/microformats-dark-data-and-css-part-1/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>The importance of being&#160;!important</title>
		<link>http://hexmen.com/blog/2007/01/the-importance-of-being-important/</link>
		<comments>http://hexmen.com/blog/2007/01/the-importance-of-being-important/#comments</comments>
		<pubDate>Thu, 18 Jan 2007 19:00:43 +0000</pubDate>
		<dc:creator>Ash</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://hexmen.com/blog/2007/01/the-importance-of-being-important/</guid>
		<description><![CDATA[There are plenty of good articles describing how CSS specificity is calculated for normal rule-sets, but the !important modifier is often ignored or overlooked. However, with a little manipulation, !important can simply be treated as one more factor in the specificity calculation. To see how this works, consider this rule-set: p.error { height: 23px; color: [...]]]></description>
			<content:encoded><![CDATA[<p>There are plenty of good articles describing how CSS specificity is calculated for normal rule-sets, but the <code>!important</code> modifier is often ignored or overlooked.  However, with a little manipulation, <code>!important</code> can simply be treated as one more factor in the specificity calculation.</p>
<p><span id="more-19"></span></p>
<p>To see how this works, consider this rule-set:</p>
<pre><code class="css">p.error {
    height: 23px;
    color: red !important;
    background: black !important;
    border: 1px solid red;
    white-space: pre;
}</code></pre>
<p>Separating the <code>!important</code> properties from the rest gives:</p>
<pre><code class="css">p.error {
    color: red !important;
    background: black !important;
}
p.error {
    height: 23px;
    border: 1px solid red;
    white-space: pre;
}</code></pre>
<p>Both rule-sets have the same selector, and therefore the same specificity; but I think it helps to consider the <code>!important</code> rule-set as having a higher specificity.  We can do this by treating <code>!important</code> as part of the selector.</p>
<h3>Faux Selectors</h3>
<p>Let&#8217;s move the <code>!important</code> modifier outside the brackets:</p>
<pre><code class="css">p.error <strong>!important</strong> {
    color: red;
    background: black;
}
p.error {
    height: 23px;
    border: 1px solid red;
    white-space: pre;
}</code></pre>
<p><em>Note: although &#8220;<code>p.error !important</code>&#8221; isn&#8217;t a valid selector, I hope the intent is clear.</em></p>
<p>Using the CSS 2.1 <a href="http://www.w3.org/TR/CSS21/cascade.html#specificity">definition of specificity</a>, an inline-style would have the highest specificity (<code>1,0,0,0</code>), while <code>p.error</code> has a specificity of <code>0,0,1,1</code> (in order: <code>0</code> for not being inline, <code>0</code> <abbr title="identifiers">IDs</abbr>, 1 class, 1 element name.)  But, <code>!important</code> rules override inline-styles, and <code>!important</code> inline-styles override everything; so wouldn&#8217;t it make sense to give <code>!important</code> rulesets a higher specificity?</p>
<p>Here&#8217;s the instruction used to calculate the first number in the specificity of a selector:</p>
<blockquote><p>count 1 if the declaration is from is a &#8216;style&#8217; attribute rather than a rule with a selector, 0 otherwise (= a) (In HTML, values of an element&#8217;s &#8220;style&#8221; attribute are style sheet rules. These rules have no selectors, so a=1, b=0, c=0, and d=0.)</p></blockquote>
<p>I suggest modifying that to: <em>count 1 if the declaration is from a &#8216;style&#8217; attribute, 0 otherwise.  Add 2 if it&#8217;s <code>!important</code> (= a)</em>.</p>
<p>Effectively, all we do for <code>!important</code> rulesets is to add <code>2,0,0,0</code> to the normal specificity.</p>
<h3>Summary</h3>
<p>By considering <code>!important</code> properties as belonging to a ruleset of their own, we can list four levels of specificity.  In decreasing order of importance, these are:</p>
<ol>
<li><code>!important</code> inline-styles (<code>3,0,0,0</code>)</li>
<li><code>!important</code> rulesets (<code>2,<var>b</var>,<var>c</var>,<var>d</var></code>)</li>
<li>standard inline-styles (<code>1,0,0,0</code>)</li>
<li>standard rulesets (<code>0,<var>b</var>,<var>c</var>,<var>d</var></code>)</li>
</ol>
<p>As you can see, <code>!important</code> rulesets still compete over the <var>b</var>, <var>c</var> and <var>d</var> of specificity, and that&#8217;s where the difficulties usually lie.</p>
]]></content:encoded>
			<wfw:commentRss>http://hexmen.com/blog/2007/01/the-importance-of-being-important/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fixing Firebug&#8217;s Style&#160;Tab</title>
		<link>http://hexmen.com/blog/2006/12/fixing-firebugs-style-tab/</link>
		<comments>http://hexmen.com/blog/2006/12/fixing-firebugs-style-tab/#comments</comments>
		<pubDate>Mon, 11 Dec 2006 10:13:40 +0000</pubDate>
		<dc:creator>Ash</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://hexmen.com/blog/2006/12/fixing-firebugs-style-tab/</guid>
		<description><![CDATA[Some users upgrading to the new Firebug Beta are having problems using the <strong>Style</strong> tab.  There is a short three-step procedure for fixing the problem, described here.]]></description>
			<content:encoded><![CDATA[<p>Lots of people are unable to use the <strong>Style</strong> tab in the new <a href="http://www.getfirebug.com/downloads.html" title="Download Firebug at www.getfirebug.com">Firebug</a> beta.  The <a href="http://getfirebug.com/faq.html">Firebug FAQ</a> leads to a thread suggesting this fix:</p>
<ol>
<li>Uninstall Firefox</li>
<li>Delete the (left-over) install folder (e.g. <code>C:\Program Files\Mozilla Firefox</code>)</li>
<li>Reinstall Firefox using a <em>custom install</em> (to ensure the DOM Inspector is installed</li>
</ol>
<p>Knowing that I already had the DOM Inspector installed, I thought I&#8217;d try removing just a few files, instead of the whole install folder.  Whatever I did worked, and the <strong>Style</strong> tab works for me now.  This more conservative procedure is:</p>
<ol>
<li>Uninstall Firefox</li>
<li>Delete only the named <code>inspector</code>* in <code>C:\Program Files\Mozilla Firefox\components</code>
</li>
<li>Reinstall Firefox using a <em>custom install</em> (to ensure the DOM Inspector is installed</li>
</ol>
<p>I&#8217;m not sure whether the uninstall and reinstall procedure is strictly necessary, so I&#8217;m hoping someone out there can try this:</p>
<ol>
<li>Stop Firefox</li>
<li>Delete all files named <code>inspector</code>* in <code>C:\Program Files\Mozilla Firefox\components</code>
</li>
<li>Restart Firefox</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://hexmen.com/blog/2006/12/fixing-firebugs-style-tab/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

