<?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>Thin &#38; Light &#187; Development</title>
	<atom:link href="http://thinlight.org/category/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://thinlight.org</link>
	<description>Passion for the web</description>
	<lastBuildDate>Sun, 30 May 2010 06:04:01 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Ruby HTML Parsers</title>
		<link>http://thinlight.org/2010/05/29/ruby-html-parsers/</link>
		<comments>http://thinlight.org/2010/05/29/ruby-html-parsers/#comments</comments>
		<pubDate>Sat, 29 May 2010 15:47:27 +0000</pubDate>
		<dc:creator>thinlight</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://thinlight.org/?p=98</guid>
		<description><![CDATA[Sometimes you need to crawl a web page and extract specific data from it. It doesn&#8217;t have to be &#8220;evil&#8221; things like crawling competitors&#8217; data. For example, you may want to do periodical checks for unreachable links in your own web pages &#8211; extract all links on the page and see if they&#8217;re still accessible.
For [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes you need to crawl a web page and extract specific data from it. It doesn&#8217;t have to be &#8220;evil&#8221; things like crawling competitors&#8217; data. For example, you may want to do periodical checks for unreachable links in your own web pages &#8211; extract all links on the page and see if they&#8217;re still accessible.</p>
<p>For extracting specific parts from some text, we tend to think about regular expressions first. For example, the regular expression for extracting links might look like:</p>
<pre><code>/&lt;a.*?href=".*?"&gt;/im</code></pre>
<p><span id="more-98"></span></p>
<p>This regular expression is too simple and it can easily cause problems. The quotes may be single or double or they may be totally omitted. There can be spaces on both sides of equal sign. Thinking about all the &#8220;special&#8221; conditions is difficult.</p>
<p>Of course the better method should be getting a DOM tree from the HTML document, like we do in JavaScript. It&#8217;s so easy to get all links in JavaScript &#8211; <code>document.getElementsByTagName("a")</code>. For more complex situations, there are so many handy frameworks like jQuery, prototype, etc. Though we normally don&#8217;t use JavaScript outside a browser, there are also libraries for parsing HTML documents in other languages (If everyone writes HTML as well-formed XML, we could just use XML parsers <img src='http://thinlight.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ).</p>
<p>I recently did a search for such parsers in Ruby, and found two: <a href="http://hpricot.com/">Hpricot</a> and <a href="http://nokogiri.org/">Nokogiri</a>. Sadly I didn&#8217;t get Hpricot to work correctly on my Mac, but Nokogiri did work. I have been using jQuery extensively in web development, so I love the CSS selectors in Nokogiri very much. They also provide searching methods based on XPath.</p>
<p>Of course if you just want to extract the title of the HTML document, using regular expressions is convenient enough and often faster than parsing the entire HTML document into a tree. But in more complex situations, you should consider a HTML parser like Nokogiri because they&#8217;re more robust and safer.</p>
<p>And it&#8217;s interesting to see that Nokogiri and Hpricot are competing on performance&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://thinlight.org/2010/05/29/ruby-html-parsers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>lighttpd, web.py, spawning fcgi failed</title>
		<link>http://thinlight.org/2009/12/26/lighttpd-web-py-spawning-fcgi-failed/</link>
		<comments>http://thinlight.org/2009/12/26/lighttpd-web-py-spawning-fcgi-failed/#comments</comments>
		<pubDate>Sun, 27 Dec 2009 05:43:42 +0000</pubDate>
		<dc:creator>thinlight</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://thinlight.org/?p=88</guid>
		<description><![CDATA[The other day I was trying to deploy my newly written app on my VPS. It&#8217;s written based on the neat framework of web.py and I was planning to deploy it on lighttpd through fastcgi.
The process was not very smooth for me, as we always expect when trying out new things. The lighttpd server failed [...]]]></description>
			<content:encoded><![CDATA[<p>The other day I was trying to deploy my newly written app on my VPS. It&#8217;s written based on the neat framework of <a href="http://webpy.org/">web.py</a> and I was planning to deploy it on <a href="http://www.lighttpd.net/">lighttpd</a> through fastcgi.</p>
<p>The process was not very smooth for me, as we always expect when trying out new things. The lighttpd server failed to start and by looking into the error log I found these lines:</p>
<p><code><br />
2009-12-15 19:48:04: (server.c.1503) server stopped by UID = 0 PID = 25128 2009-12-15 19:48:30: (log.c.166) server started<br />
2009-12-15 19:48:30: (mod_fastcgi.c.1104) the fastcgi-backend /var/www/code.py failed to start:<br />
2009-12-15 19:48:30: (mod_fastcgi.c.1108) child exited with status 1 /var/www/code.py<br />
2009-12-15 19:48:30: (mod_fastcgi.c.1111) If you're trying to run your app as a FastCGI backend, make sure you're using the FastCGI-enabled version.If this is PHP on Gentoo, add 'fastcgi' to the USE flags.<br />
2009-12-15 19:48:30: (mod_fastcgi.c.1399) [ERROR]: spawning fcgi failed. 2009-12-15 19:48:30: (server.c.931) Configuration of plugins failed. Going down.<br />
</code></p>
<p>Finally I got it to work and here I&#8217;ll provide a check list in case someone else encounter the same problem.</p>
<h3>Is code.py executable?</h3>
<p>If not:</p>
<blockquote><p>chmod 755 code.py</p></blockquote>
<p>Also you need something like this on top of file:</p>
<blockquote><p>#!/usr/bin/env python</p></blockquote>
<h3>Does helloword example work?</h3>
<p>Use the example on web.py&#8217;s homepage (remember to add the line of python executable to the top of the file):</p>
<pre><code>
#!/usr/bin/env python
import web

urls = (
    '/(.*)', 'hello'
)
app = web.application(urls, globals())

class hello:
    def GET(self, name):
        if not name:
            name = 'world'
        return 'Hello, ' + name + '!'

if __name__ == "__main__":
    app.run()
</code></pre>
<p>Chances are this will work. Because this app is so simple and it doesn&#8217;t require many libraries.</p>
<h3>check egg cache dir permission</h3>
<p>Some libraries need to extract files to a directory (python egg cache). I used MySQL-python in my program and it might fail on that.<br />
/sbin/.python-eggs/<br />
Now change the GET method of hello class to:</p>
<pre><code>
try:
    import MySQLdb
except Exception, e:
    return str(e);
return 'hello'
</code></pre>
<p>If egg cache permission is the cause, you&#8217;ll see something like this when visiting the server:</p>
<blockquote><p>Can&#8217;t extract file(s) to egg cache The following error occurred while trying to extract file(s) to the Python egg cache: [Errno 13] Permission denied: &#8216;/sbin/.python-eggs&#8217; The Python egg cache directory is currently set to: /sbin/.python-eggs Perhaps your account does not have write access to this directory? You can change the cache directory by setting the PYTHON_EGG_CACHE environment variable to point to an accessible directory.</p></blockquote>
<p>There are many ways to solve this problem, but I just changed the owner of this directory to the user who runs lighttpd (daemon in my case):</p>
<blockquote><p>chown -R daemon.daemon /sbin/.python-eggs</p></blockquote>
<h3>Is lighttpd using the expected version of python?</h3>
<p>My VPS is running CentOS 5.4 and I installed python 2.6 on it (CentOS ships with old 2.4 version). I have two python executables (/usr/local/bin/python and /usr/bin/python) on my $PATH, but python 2.6 has precedence on mine (root). At last it turned out that lighttpd was using the old python 2.4</p>
<p>So I changed the first line of code.py to be:</p>
<blockquote><p>#!/usr/local/bin/python</p></blockquote>
<p>Now lighttpd can start happily.</p>
]]></content:encoded>
			<wfw:commentRss>http://thinlight.org/2009/12/26/lighttpd-web-py-spawning-fcgi-failed/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>When working in an old system</title>
		<link>http://thinlight.org/2009/05/11/when-working-in-an-old-system/</link>
		<comments>http://thinlight.org/2009/05/11/when-working-in-an-old-system/#comments</comments>
		<pubDate>Mon, 11 May 2009 14:32:43 +0000</pubDate>
		<dc:creator>thinlight</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://thinlight.org/?p=87</guid>
		<description><![CDATA[Today I needed to pull some web page down from the internet and extract some specific contents in PHP. Sounds like a crawler, huh? Actually not the real crawler, just pulling our own contents. I was doing this because it&#8217;s not convenient for me to access the database directly.
I&#8217;m not quite familiar with PHP, but [...]]]></description>
			<content:encoded><![CDATA[<p>Today I needed to pull some web page down from the internet and extract some specific contents in PHP. Sounds like a crawler, huh? Actually not the real crawler, just pulling our own contents. I was doing this because it&#8217;s not convenient for me to access the database directly.</p>
<p>I&#8217;m not quite familiar with PHP, but with version 5 on my local dev machine, I was able to do this very quickly. Just use <a href="http://php.net/manual/en/function.file-get-contents.php">file_get_contents</a> to get the whole page as a string, and then use <a href="http://php.net/manual/en/function.preg-match-all.php">preg_match_all</a> to search for the parts I want.</p>
<p>Unexpected things happened after I uploaded the script to the server. It said function file_get_contents was not defined. Then I realized that I was on a machine with Red Hat 9, the PHP I was using was version 4.2.2 bundled with RH9. OK. I rewrote the code to use fopen/fread directly. This time, it complained that it couldn&#8217;t handle the scheme (I don&#8217;t remember the error report string clearly).</p>
<p>I don&#8217;t know if it was because of my configuration, or version 4.2.2 doesn&#8217;t support the <a href="http://php.net/manual/en/wrappers.php">wrappers</a>. It made me crazy. I don&#8217;t want to do an upgrade because all the packages are old. It takes time and may cause more problems. I even couldn&#8217;t find the apxs binary to compile PHP from source.</p>
<p>Finally, I got a workaround. First use <a href="http://php.net/manual/en/function.exec.php">exec</a> to call wget to download the url to a file in /tmp, and then use fopen/fread to read this temp file. It really works.</p>
<p>Another problem was that preg_match_all doesn&#8217;t accept the last $offset parameter in PHP 4.2.2, but it&#8217;s simple to fix, I think.</p>
<p>This took me some time, but made me realize that how the development of software/language tools eased our daily work.</p>
]]></content:encoded>
			<wfw:commentRss>http://thinlight.org/2009/05/11/when-working-in-an-old-system/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MyBlogLog Changed its Widget Theme</title>
		<link>http://thinlight.org/2008/07/26/mybloglog-changed-its-widget-theme/</link>
		<comments>http://thinlight.org/2008/07/26/mybloglog-changed-its-widget-theme/#comments</comments>
		<pubDate>Sat, 26 Jul 2008 11:12:03 +0000</pubDate>
		<dc:creator>thinlight</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[MyBlogLog]]></category>

		<guid isPermaLink="false">http://thinlight.org/?p=72</guid>
		<description><![CDATA[Half a year ago I wrote a small tool for customizing MyBlogLog widget. And, since then I didn&#8217;t notice the changes MyBlogLog has done.
As I noticed there are some problems with the widget colorer, I checked MyBlogLog and found that they&#8217;ve changed the widget theme.
Well, the new theme is polished and cool but lacks flexibility [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://thinlight.org/2008/01/05/mybloglog-widget-colorer/">Half a year ago</a> I wrote <a href="http://thinlight.org/toolbox/mybloglog/widget-colorer/">a small tool</a> for customizing <a href="http://www.mybloglog.com/">MyBlogLog</a> widget. And, since then I didn&#8217;t notice the changes MyBlogLog has done.</p>
<p>As I noticed there are some problems with the widget colorer, I checked MyBlogLog and found that they&#8217;ve changed the widget theme.</p>
<p>Well, the new theme is polished and cool but lacks flexibility due to the gradient background.</p>
<p>So I must mark the project as &#8220;obsolete&#8221;. But people still can play around with it, and the &#8220;obsolete&#8221; code can still be used on websites.</p>
]]></content:encoded>
			<wfw:commentRss>http://thinlight.org/2008/07/26/mybloglog-changed-its-widget-theme/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Google Maps API&#8217;s Error Handling</title>
		<link>http://thinlight.org/2008/02/02/google-maps-apis-error-handling/</link>
		<comments>http://thinlight.org/2008/02/02/google-maps-apis-error-handling/#comments</comments>
		<pubDate>Sat, 02 Feb 2008 18:17:13 +0000</pubDate>
		<dc:creator>thinlight</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[Google Maps]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://thinlight.org/2008/02/02/google-maps-apis-error-handling/</guid>
		<description><![CDATA[Requirements to try out things described below:

Firefox
Firebug (extension for Firefox)

Super large numbers as LatLng&#8217;s
Open this page from Google&#8217;s example. In firebug&#8217;s console, execute the following code:
map.setCenter(new GLatLng(1e100, 1e100));
Setting super large numbers as latitude and longitude like this always makes my Firefox 2.0.0.11 in Windows XP hang.
I don&#8217;t know why Google didn&#8217;t restrict the range of [...]]]></description>
			<content:encoded><![CDATA[<p>Requirements to try out things described below:</p>
<ul>
<li><a href="http://www.mozilla.com/en-US/firefox/">Firefox</a></li>
<li><a href="http://getfirebug.com/">Firebug</a> (extension for Firefox)</li>
</ul>
<h3>Super large numbers as LatLng&#8217;s</h3>
<p>Open <a target="_blank" href="http://code.google.com/apis/maps/documentation/examples/geocoding-extraction.html">this page</a> from Google&#8217;s example. In firebug&#8217;s console, execute the following code:</p>
<pre><code>map.setCenter(new GLatLng(1e100, 1e100));</code></pre>
<p>Setting super large numbers as latitude and longitude like this always makes my Firefox 2.0.0.11 in Windows XP hang.</p>
<p>I don&#8217;t know why Google didn&#8217;t restrict the range of the numbers, and what computation it did to consume so much CPU time. It should ignore such numbers after a simple judgment.</p>
<h3>Strings as zoom parameters</h3>
<p>In the same page, execute this piece of code:</p>
<pre><code>var zoom = '16';
map.setZoom(zoom);</code></pre>
<p>As you see, nothing happens. Google must be ignoring the parameter when expression typeof(zoom) == &#8216;number&#8217; is false. In my situation, I got the value of variable zoom from the url, and didn&#8217;t noticed it was the type mismatch which prevented the code to work, since I&#8217;m used to JavaScript&#8217;s dynamic type conversion feature:</p>
<pre><code>a = 2 * '3'; // a = 6</code></pre>
<p>It will be converted to number when needed. Of course, it&#8217;s good to perform strict type checking. But it&#8217;ll be better if the API threw an exception instead of being silent.</p>
]]></content:encoded>
			<wfw:commentRss>http://thinlight.org/2008/02/02/google-maps-apis-error-handling/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remove Dotted Link Borders in Firefox</title>
		<link>http://thinlight.org/2008/01/08/remove-dotted-link-borders-in-firefox/</link>
		<comments>http://thinlight.org/2008/01/08/remove-dotted-link-borders-in-firefox/#comments</comments>
		<pubDate>Tue, 08 Jan 2008 16:22:45 +0000</pubDate>
		<dc:creator>thinlight</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Firefox]]></category>

		<guid isPermaLink="false">http://thinlight.org/2008/01/08/remove-dotted-link-borders-in-firefox/</guid>
		<description><![CDATA[When you use a HTML link (&#8220;&#60;a&#62;&#8221; tag) to implement a drop-down list or menu, you&#8217;ll notice that there are annoying dotted borders around the link after it&#8217;s clicked in Firefox. We can just ignore this for most of the times but sometimes it affects the look and feel of the site. Two screen shots [...]]]></description>
			<content:encoded><![CDATA[<p>When you use a HTML link (&#8220;&lt;a&gt;&#8221; tag) to implement a drop-down list or menu, you&#8217;ll notice that there are annoying dotted borders around the link after it&#8217;s clicked in Firefox. We can just ignore this for most of the times but sometimes it affects the look and feel of the site. Two screen shots from <a href="http://youtube.com/">Youtube</a> and <a href="http://youtube.com/">Yahoo!</a>:</p>
<p><img src='http://thinlight.org/wp-content/uploads/2008/01/youtube-top-right.png' alt='Youtube link border example' />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src='http://thinlight.org/wp-content/uploads/2008/01/yahoo-link-border.png' alt='Yahoo link border' /></p>
<p>This can be even worse (<a href="http://digg.com/">Digg</a> front page):</p>
<p><img src='http://thinlight.org/wp-content/uploads/2008/01/digg-link-border.png' alt='Digg Link Border' /></p>
<p>OK. This is fake <img src='http://thinlight.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  . Digg did a perfect drop-down menu, though they&#8217;re <a href="http://thinlight.org/2007/12/27/small-flaw-of-digg-podcasts/">ignoring</a> something. I removed some CSS rules using Firebug and got this effect. It&#8217;s ugly, isn&#8217;t it?</p>
<p><strong>The Cause</strong></p>
<p>When a link is clicked, it gets the focus. Firefox adds dotted borders to links that have focus to remind the users.</p>
<p><strong>The Solution</strong></p>
<p>To avoid the border, add this CSS rule to your page:</p>
<p><code>a {<br />
outline: none;<br />
}</code></p>
<p>This piece of code is similar to the code I removed from Digg to get the screen shot above.</p>
<p>In fact this is a common problem asked by many developers. For more information, search for &#8220;<a href="http://www.google.com/search?q=firefox+link+border">firefox link border</a>&#8220;. Many authors wrote good articles on this topic.</p>
<p><strong>Update</strong> &#8211; This can be seen on every WordPress blog login page (click to enlarge):</p>
<p><a href='http://thinlight.org/wp-content/uploads/2008/01/wordpress.png' title='WordPress login'><img src='http://thinlight.org/wp-content/uploads/2008/01/wordpress.thumbnail.png' alt='WordPress login' /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://thinlight.org/2008/01/08/remove-dotted-link-borders-in-firefox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Small Flaw of StumbleUpon User List (Firefox only)</title>
		<link>http://thinlight.org/2008/01/07/small-flaw-of-stumbleupon-user-list-firefox-only/</link>
		<comments>http://thinlight.org/2008/01/07/small-flaw-of-stumbleupon-user-list-firefox-only/#comments</comments>
		<pubDate>Mon, 07 Jan 2008 14:49:51 +0000</pubDate>
		<dc:creator>thinlight</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[flaw]]></category>
		<category><![CDATA[StumbleUpon]]></category>

		<guid isPermaLink="false">http://thinlight.org/2008/01/07/small-flaw-of-stumbleupon-user-list-firefox-only/</guid>
		<description><![CDATA[If you stumble a lot using Firefox, you must have already seen disordered user lists like this one (two blank seats in the second row):

This screen shot was taken from a page on StumbleUpon which received 35 reviews. StumbleUpon automatically finds out who&#8217;s living in the same city with you and places them in the [...]]]></description>
			<content:encoded><![CDATA[<p>If you stumble a lot using <strong>Firefox</strong>, you must have already seen disordered user lists like this one (two blank seats in the second row):</p>
<p><img src='http://thinlight.org/wp-content/uploads/2008/01/su-user-list.png' alt='StumbleUpon User List' /></p>
<p>This screen shot was taken from <a href="http://www.stumbleupon.com/url/imeem.com/">a page</a> on <a href="http://www.stumbleupon.com/">StumbleUpon</a> which received 35 reviews. StumbleUpon automatically finds out who&#8217;s living in the same city with you and places them in the beginning of the list. To make it more clear, StumbleUpon adds an &#8220;city&#8221; icon (<img src="http://www.stumbleupon.com/images/icon_city.gif" alt="city" />) in front of the user&#8217;s name.</p>
<p>Yes. This icon caused the mess of the list. Using Firebug to inspect the elements, I found the dimensions of the first two list items with city icon to be 145&#215;89, whereas the other items in the list have dimensions of 145&#215;88. This 1px difference, according to the CSS rule, made left-floating elements to be positioned on the right of them rather than under them.</p>
<p>In fact, just one more CSS rule will fix this issue:</p>
<p><code>div.listPeople dl {<br />
 line-height: 16px;<br />
}</code></p>
<p>Another solution is to have &#8220;clear:both&#8221; style on each element starting a row.</p>
<p>This page looks OK in all other major browsers including IE 6, Opera 9.24 and Safari 3.0.4 as I tested. However market share of Firefox is <a href="http://www.w3schools.com/browsers/browsers_stats.asp">growing steadily</a>, so websites should pay enough attention on it. Besides, with the great power of Firebug, it&#8217;s much easier to develop a site for Firefox compared to the ancient browser &#8211; IE.</p>
]]></content:encoded>
			<wfw:commentRss>http://thinlight.org/2008/01/07/small-flaw-of-stumbleupon-user-list-firefox-only/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Readonly Text Input Background Color in Firefox</title>
		<link>http://thinlight.org/2007/12/12/readonly-text-input-background-color-in-firefox/</link>
		<comments>http://thinlight.org/2007/12/12/readonly-text-input-background-color-in-firefox/#comments</comments>
		<pubDate>Wed, 12 Dec 2007 15:13:50 +0000</pubDate>
		<dc:creator>thinlight</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Firefox]]></category>

		<guid isPermaLink="false">http://thinlight.org/2007/12/12/readonly-text-input-background-color-in-firefox/</guid>
		<description><![CDATA[The other day I was stuck when trying to make the background-color of a readonly text input white in Firefox.
Today lots of sites are using readonly text inputs to carry out some urls for propagation or some code snippets for embedding in your own pages. For example, every Youtube video has such a input field [...]]]></description>
			<content:encoded><![CDATA[<p>The other day I was stuck when trying to make the background-color of a readonly text input white in Firefox.</p>
<p>Today lots of sites are using readonly text inputs to carry out some urls for propagation or some code snippets for embedding in your own pages. For example, every <a href="http://youtube.com/">Youtube</a> video has such a input field just on the right of it. When you click on it, the text gets selected and you can press Ctrl+C to copy it to the clipboard.</p>
<p>The code is like this:</p>
<p><code>&lt;input type="text" readonly="readonly" value="some read only text..." onclick="this.select()" /&gt;</code></p>
<p>and the rendered output:</p>
<input type="text" readonly="readonly" value="some read only text..." onclick="this.select()" />
<p>In all other major browsers it looks like a normal text input. But in Firefox, the background color is made gray (#D6D5D9, actually), maybe emphasizing the difference. There are always cases when we want to make it white. But when added &#8220;background-color:#FFFFFF;&#8221;, it showed no difference. At that time I thought I couldn&#8217;t change the background color.</p>
<p>But soon I found the &#8220;white&#8221; text input when watching <a href="http://www.metacafe.com/watch/967494/puppy_vs_cat/">this video</a> (I love the puppy!). After inspecting the code with Firebug I found it was &#8220;border:1px solid #D2D2D0&#8243; who did the trick. Adding it to the example code above:</p>
<input type="text" readonly="readonly" style="border:1px solid #D2D2D0;" value="some read only text..." onclick="this.select()" />
<p>Then I found that the background color is ok with any color except #FFFFFF. For example, setting it to &#8220;#FEFEFE&#8221; (Almost white. And note the default border style is &#8220;outset&#8221;):</p>
<input type="text" readonly="readonly" style="background-color:#FEFEFE;" value="some read only text..." onclick="this.select()" />
<p>Weird, isn&#8217;t it? I don&#8217;t know if it&#8217;s a bug or &#8220;feature&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://thinlight.org/2007/12/12/readonly-text-input-background-color-in-firefox/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
