 <?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>Broken Links &#187; browsers</title>
	<atom:link href="http://www.broken-links.com/category/browsers/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.broken-links.com</link>
	<description>Thoughts on web development and technologies by Peter Gasston</description>
	<lastBuildDate>Fri, 30 Jul 2010 00:10:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<atom:link rel='hub' href='http://www.broken-links.com/?pushpress=hub'/>
		<item>
		<title>New to Firefox: –moz-calc and :-moz-any</title>
		<link>http://www.broken-links.com/2010/05/17/new-to-firefox-moz-calc-and-moz-any/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=new-to-firefox-moz-calc-and-moz-any</link>
		<comments>http://www.broken-links.com/2010/05/17/new-to-firefox-moz-calc-and-moz-any/#comments</comments>
		<pubDate>Mon, 17 May 2010 13:00:37 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[browsers]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[calculations]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[experimental]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[mozilla]]></category>
		<category><![CDATA[selectors]]></category>

		<guid isPermaLink="false">http://www.broken-links.com/?p=795</guid>
		<description><![CDATA[The latest nightly releases of what will become Firefox 4 have implemented a couple of experimental new CSS features. The –moz-calc function allows calculations on length values, and the :-moz-any selector permits grouping of simple selectors. If you have a nightly build of Firefox you can see a little demo I’ve put together of them [...]]]></description>
			<content:encoded><![CDATA[<p>The latest nightly releases of what will become Firefox 4 have <a href="http://www.squarefree.com/burningedge/2010/05/12/2010-05-12-trunk-builds/">implemented a couple of experimental new CSS features</a>. The <code>–moz-calc</code> function allows calculations on length values, and the <code>:-moz-any</code> selector permits grouping of simple selectors.</p>
<p>If you have a <a href="http://www.mozilla.org/developer/#builds">nightly build of Firefox</a> you can see a little <a href="http://www.broken-links.com/tests/calc-any/">demo</a> I’ve put together of them in action.</p>
<p><span id="more-795"></span></p>
<p>The first new property is <code>–moz-calc</code>, which is the experimental implementation of CSS3’s <a href="http://www.w3.org/TR/css3-values/#calc"><code>calc</code> function</a>. This allows you to perform simple mathematical functions on length values.</p>
<p>Take a look at the <a href="http://www.broken-links.com/tests/calc-any/">demo</a>, where you’ll see two <code>h2</code> elements; both have the same styles applied to them, but the second also has some extra <code>calc</code> values for some of its properties:</p>
<pre>font-size: -moz-calc(120% * 3);
letter-spacing: -moz-calc(0 + 2px);
text-shadow: rgba(0,0,0,0.33) -moz-calc(4px / 2) -moz-calc(4px / 2);
word-spacing: -moz-calc(0.75em - 0.25em);</pre>
<p>The <code>font-size property</code> has a value of <em>120% * 3</em>, or <em>360%;</em> the <code>letter-spacing</code> property has a value of <em>0 + 2px</em>, or <em>2px</em>; the <code>text-shadow</code> property has x and y offset values of <em>4px / 2</em>, or <em>2px</em>; and the <code>word-spacing</code> property has a value of <em>0.75em — 0.25em</em>, or <em>0.5em</em>.</p>
<p>The values themselves are abitrary and not important; what matters is that we’re doing calculations in CSS!</p>
<p>At the moment the only properties which support <code>–moz-calc</code> values are:<code>–moz-column-rule-width</code>, <code>–moz-column-width</code>, <code>letter-spacing</code>, <code>word-spacing</code>, <code>marker-offset</code>, <code>outline-offset</code>, <code>border-spacing</code>, <code>text-shadow</code> and <code>–moz-box-shadow</code>; but work is underway to add this to all properties which accept length values.</p>
<p><strong>Update:</strong> You can read more about <code>calc()</code> at <a href="http://hacks.mozilla.org/2010/06/css3-calc/">hacks.mozilla.org</a>.</p>
<p>Also implemented is a new selector, <code>:-moz-any</code>. With this you can group other simple selectors, removing the need for repetitive code. Consider, for example, a typical web page which has many types of list, and nested lists:</p>
<pre>
&lt;ul&gt;
  &lt;li&gt;We are all list items now
    &lt;ul&gt;
      &lt;li&gt;We are all list items now&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;
&lt;ol&gt;
  &lt;li&gt;We are all list items now
    &lt;ul&gt;
      &lt;li&gt;We are all list items now&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ol&gt;
&lt;menu&gt;
  &lt;li&gt;We are all list items now
    &lt;ul&gt;
      &lt;li&gt;We are all list items now&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/menu&gt;
</pre>
<p>If we wanted to select all of the <code>li</code> children of nested <code>ul</code> elements we would currently have to do this:</p>
<pre>ul ul li, ol ul li, menu ul li { property: value; }</pre>
<p>But with <code>–moz-any</code> we can group the selectors like so:</p>
<pre>:-moz-any(ul,ol,menu) ul li { property: value; }</pre>
<p>In my <a href="http://www.broken-links.com/tests/calc-any/">demo</a> page I’ve provided a couple of examples; the first selects all list types which are direct child elements of the body:</p>
<pre>body > :-moz-any(ol, ul, menu) {
	float: left;
	width: 33%;
}</pre>
<p>And the next selects list items of the lists which are children of those elements:</p>
<pre>:-moz-any(ol, ul, menu) ul li {
	font-weight: bold;
	margin-left: 0;
}</pre>
<p>The <code>:any</code> selector isn’t in any of the CSS3 modules, but it’s pretty useful and definitely a candidate for inclusion. You can read more about it on <a href="http://dbaron.org/log/20100424-any">the blog of David Baron</a>.</p>
<p><strong>Update: </strong>Changed the examples for clarity.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.broken-links.com/2010/05/17/new-to-firefox-moz-calc-and-moz-any/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Help wanted: Webkit multi-columns</title>
		<link>http://www.broken-links.com/2010/02/16/help-wanted-webkit-multi-columns/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=help-wanted-webkit-multi-columns</link>
		<comments>http://www.broken-links.com/2010/02/16/help-wanted-webkit-multi-columns/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 20:09:51 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[Asides]]></category>
		<category><![CDATA[browsers]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[multiple columns]]></category>

		<guid isPermaLink="false">http://www.broken-links.com/?p=701</guid>
		<description><![CDATA[I’m writing about the CSS3 Multi-column layout module and I notice that WebKit supports a series of proprietary properties: –webkit-column-break-after, –webkit-column-break-before, and –webkit-column-break-inside. However, despite the documentation saying that they’re implemented in Safari 3+, I can’t seem to get any of them to work. Has anyone reading this ever seen an example of these in [...]]]></description>
			<content:encoded><![CDATA[<p>I’m writing about the CSS3 Multi-column layout module and I notice that WebKit supports a series of proprietary properties: <code>–webkit-column-break-after</code>, <code>–webkit-column-break-before</code>, and <code>–webkit-column-break-inside</code>. However, despite the documentation saying that they’re implemented in Safari 3+, I can’t seem to get any of them to work.</p>
<p>Has anyone reading this ever seen an example of these in action? I’ve searched for demos but have found nothing. If you know anything about this, please leave me a comment; your help would be gratefully appreciated.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.broken-links.com/2010/02/16/help-wanted-webkit-multi-columns/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Opera 10.5 has support for CSS transforms</title>
		<link>http://www.broken-links.com/2009/12/22/opera-10-5-has-support-for-css-transforms/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=opera-10-5-has-support-for-css-transforms</link>
		<comments>http://www.broken-links.com/2009/12/22/opera-10-5-has-support-for-css-transforms/#comments</comments>
		<pubDate>Tue, 22 Dec 2009 20:28:30 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[Asides]]></category>
		<category><![CDATA[browsers]]></category>
		<category><![CDATA[css]]></category>

		<guid isPermaLink="false">http://www.broken-links.com/?p=680</guid>
		<description><![CDATA[The Opera team have released a very early preview of their next browser, which features an updated version of their Presto rendering engine. Opera 10.5 will support CSS transforms and transitions, so I’ve updated the demos on my old post, Anime with CSS and WebKit, to reflect that.]]></description>
			<content:encoded><![CDATA[<p>The Opera team have released <a href="http://labs.opera.com/news/2009/12/22/">a very early preview of their next browser</a>, which features an updated version of their Presto rendering engine. Opera 10.5 will support CSS transforms and transitions, so I’ve updated the demos on my old post, <a href="http://www.broken-links.com/2008/07/11/anime-with-css-and-webkit/">Anime with CSS and WebKit</a>, to reflect that.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.broken-links.com/2009/12/22/opera-10-5-has-support-for-css-transforms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Firefox 3.6 uses the W3C File API</title>
		<link>http://www.broken-links.com/2009/12/15/firefox-3-6-uses-the-w3c-file-api/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=firefox-3-6-uses-the-w3c-file-api</link>
		<comments>http://www.broken-links.com/2009/12/15/firefox-3-6-uses-the-w3c-file-api/#comments</comments>
		<pubDate>Tue, 15 Dec 2009 22:23:04 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[OS]]></category>
		<category><![CDATA[browsers]]></category>
		<category><![CDATA[standards]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[file api]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[firefox 3.6]]></category>

		<guid isPermaLink="false">http://www.broken-links.com/?p=670</guid>
		<description><![CDATA[Last month the W3C released a working draft of the <a href="http://www.w3.org/TR/FileAPI/">File API</a>, which <q cite="http://www.w3.org/TR/FileAPI/">defines the basic representations for files, lists of files, errors raised by access to files, and programmatic ways to read files</q>. The Firefox team <a href="http://hacks.mozilla.org/2009/12/w3c-fileapi-in-firefox-3-6/">have already implemented much of it</a>, and have released a series of impressive demos on <a href="http://hacks.mozilla.org/">hacks.mozilla.org</a>, which you can see if you have a recent beta of Firefox 3.6 (or a nightly trunk build).]]></description>
			<content:encoded><![CDATA[<p>Last month the W3C released a working draft of the <a href="http://www.w3.org/TR/FileAPI/">File API</a>, which <q cite="http://www.w3.org/TR/FileAPI/">defines the basic representations for files, lists of files, errors raised by access to files, and programmatic ways to read files</q>. The Firefox team <a href="http://hacks.mozilla.org/2009/12/w3c-fileapi-in-firefox-3-6/">have already implemented much of it</a>, and have released a series of impressive demos on <a href="http://hacks.mozilla.org/">hacks.mozilla.org</a>, which you can see if you have a recent beta of Firefox 3.6 (or a nightly trunk build).</p>
<p>The four demos shown to date display different (although related) aspects of the API, showing first <a href="http://hacks.mozilla.org/2009/12/multiple-file-input-in-firefox-3-6/">multiple file uploads</a>, then a <a href="http://hacks.mozilla.org/2009/12/file-drag-and-drop-in-firefox-3-6/">drag and drop upload interface</a>, next adding <a href="http://hacks.mozilla.org/2009/12/uploading-files-with-xmlhttprequest/">progress information</a> (although this doesn’t work for me), then <a href="http://hacks.mozilla.org/2009/12/firefox-36-fileapi-demo-reading-exif-data-from-a-local-jpeg-file/">reading EXIF data from a JPEG image</a>. You can imagine how these combined would be used for native drag and drop uploading to Flickr, for example.</p>
<p>The File API plays a big part in integrating the browser more tightly with the OS, particularly when combined with the drag and drop functionality, and I’m sure it’s only a matter of time until the other browsers implement this. Congratulations to the Firefox team for their work on this, and hacks.mozilla.org for some great demos.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.broken-links.com/2009/12/15/firefox-3-6-uses-the-w3c-file-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS gradient syntax: comparison of Mozilla and WebKit (Part 2)</title>
		<link>http://www.broken-links.com/2009/11/30/css-gradient-syntax-comparison-of-mozilla-and-webkit-part-2/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=css-gradient-syntax-comparison-of-mozilla-and-webkit-part-2</link>
		<comments>http://www.broken-links.com/2009/11/30/css-gradient-syntax-comparison-of-mozilla-and-webkit-part-2/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 19:23:11 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[browsers]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[standards]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[mozilla]]></category>
		<category><![CDATA[syntax]]></category>
		<category><![CDATA[webkit]]></category>

		<guid isPermaLink="false">http://www.broken-links.com/?p=649</guid>
		<description><![CDATA[In <a href="/2009/11/26/css-gradient-syntax-comparison-of-mozilla-and-webkit/">the first part of this post</a> I gave a potted history of the differing syntaxes, and provided an overview of how that affected linear gradients. In this second part I'm going to look at radial gradients.

Here the syntaxes diverge slightly more, with WebKit requiring more values than Mozilla; while that adds some flexibility, it also increases the complexity.]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://www.broken-links.com/2009/11/26/css-gradient-syntax-comparison-of-mozilla-and-webkit/">the first part of this post</a> I gave a potted history of the differing syntaxes, and provided an overview of how that affected linear gradients. In this second part I’m going to look at radial gradients.</p>
<p>Here the syntaxes diverge slightly more, with WebKit requiring more values than Mozilla; while that adds some flexibility, it also increases the complexity.</p>
<p><span id="more-649"></span></p>
<p>I’ll be using the same page of examples, which you’ll need to view in Safari / Chrome (or other WebKit derivative) or Firefox 3.6 (beta 3+):</p>
<p><a href="http://www.broken-links.com/tests/gradients/">CSS Gradients comparison: Mozilla &amp; WebKit</a></p>
<h2>Radial gradients</h2>
<p>As with linear gradients, the key differentiation between the <a href="https://developer.mozilla.org/en/CSS/-moz-radial-gradient">Mozilla syntax</a> and the <a href="http://developer.apple.com/safari/library/documentation/AppleApplications/Reference/SafariCSSRef/Articles/Functions.html#//apple_ref/doc/uid/TP40007955-SW25">WebKit syntax</a> is that the latter requires a start and end point, whereas the former is constrained by the bounding box.</p>
<p>You can see in this first example (<strong>Radial 1</strong>) that the Mozilla syntax is much shorter when making a simple two-colour radial gradient:</p>
<pre>-moz-radial-gradient(green, yellow);
-webkit-gradient(radial, center center, 0, center center, 70.5, from(green), to(yellow));</pre>
<p>In Mozilla’s case I set only start and end <code>color-stop</code>s; for WebKit I must specify a position (<em>50% 50%</em>) and radius (<em>0</em> — I’ll explain that later) for the start point, and a position (<em>50% 50%</em>) and radius (<em>70.5</em>) for the end point, as well as the <code>color-stop</code>s.</p>
<p>As far as I can see the radius value has to be a value in pixels, so in order for the end radius to be the diagonal of the square (where Mozilla defaults to) you need to use the calculation<em> (side)(sqrt(2))</em> — or, do what I did and use this <a href="http://easycalculation.com/area/square.php">online calculator</a>.</p>
<p>In the next example (<strong>Radial 2</strong>) I’ve offset the center of the gradient and set it to end at the furthest edge of the containing box:</p>
<pre>-moz-radial-gradient(40% 40%, farthest-side, green, yellow);
-webkit-gradient(radial, 40% 40%, 0, 40% 40%, 60, from(green), to(yellow));</pre>
<p>And then used the same center offset but constrained the radius to the distance of the nearest wall (<strong>Radial 3</strong>):</p>
<pre>-moz-radial-gradient(40% 40%, closest-side, green, yellow);
-webkit-gradient(radial, 40% 40%, 0, 40% 40%, 40, from(green), to(yellow));</pre>
<p>As you can see, Mozilla takes a series of constants using natural language — <code>farthest-side</code>, <code>closest-side</code>, <code>contain</code>, etc — to set the limits of the gradient, where WebKit accepts only pixel values. The advantage to the former approach is that the syntax is simpler and no calculations are required; the disadvantage is that if you want to create a radial gradient that is smaller than the limits of the containing box, you have to combine it with the <code>background-size</code> property.</p>
<p>Next (<strong>Radial 4</strong>) I’ve set the center of the gradient to the top-right corner, using three colours equally distributed; here’s where you can start to see the WebKit syntax start to become really unwieldy:</p>
<pre>-moz-radial-gradient(right top, green, yellow, blue);
-webkit-gradient(radial, right top, 0, right top, 141, from(green), color-stop(50%, yellow), to(blue));</pre>
<p>With WebKit I again have to specify start and end points (with radii), and also specify the stop position of the middle colour. Both outcomes are the same, but the Mozilla syntax is significantly easier.</p>
<p>One aspect of WebKit’s syntax which allows for more flexibility in a gradient is the start point and end point; by providing two separate values you can set the start gradient at a different point to the end gradient, as well as providing different radius values, allowing for effects that Mozilla can’t easily replicate (<strong>Radial 5</strong>):</p>
<pre>-moz-radial-gradient(60% 60%,circle contain,yellow,green 75%,rgba(255,255,255,0));
-webkit-gradient(radial,45% 45%,5,60% 60%,40,from(yellow),color-stop(75%, green),to(rgba(255,255,255,0)));</pre>
<p>You can see how that is rendered here (Mozilla on the left, WebKit on the right):</p>
<p><img src="/wp-content/uploads/2009/11/radial_gradient.png" alt="Comparison of CSS gradients" width="200" height="100" /></p>
<p>Achieving the same effect is only possible in Mozilla by using multiple values on the <code>background-image</code> property, <del datetime="2009-11-30T22:04:27+00:00">along with <code>background-size</code></del> (<strong>Update:</strong> This isn’t necessary; see <a href="#comment-35677">Tab Atkins Jr’s comment</a>, below).</p>
<h2>Conclusions</h2>
<p>While the (original) WebKit syntax does allow for a few effects that the simpler Mozilla implementation can’t easily copy, I think these are really edge cases and the simplicity of the newer syntax is more than ample compensation. It seems the CSS WG agree, which is why the simple syntax is to become an official proposal; I hope the WebKit team accept the proposal and implement it soon.</p>
<p>It was suggested that I also compare these with <a href="http://msdn.microsoft.com/en-us/library/ms532997%28VS.85%29.aspx">Internet Explorer’s Gradient filter</a>, but that’s a browser-specific implementation that has no chance of becoming a standard, so I didn’t feel it was suitable for this article; perhaps in a future extension.</p>
<p><strong>Update:</strong> Just after I finished this article, <a href="http://hacks.mozilla.org/2009/11/css-gradients-firefox-36/">Mozilla Hacks published an in-depth look at the new syntax</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.broken-links.com/2009/11/30/css-gradient-syntax-comparison-of-mozilla-and-webkit-part-2/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>CSS gradient syntax: comparison of Mozilla and WebKit</title>
		<link>http://www.broken-links.com/2009/11/26/css-gradient-syntax-comparison-of-mozilla-and-webkit/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=css-gradient-syntax-comparison-of-mozilla-and-webkit</link>
		<comments>http://www.broken-links.com/2009/11/26/css-gradient-syntax-comparison-of-mozilla-and-webkit/#comments</comments>
		<pubDate>Thu, 26 Nov 2009 15:48:32 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[browsers]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[standards]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[gradients]]></category>
		<category><![CDATA[mozilla]]></category>
		<category><![CDATA[webkit]]></category>

		<guid isPermaLink="false">http://www.broken-links.com/?p=624</guid>
		<description><![CDATA[CSS Gradients were <a href="http://webkit.org/blog/175/introducing-css-gradients/">originally proposed by the WebKit team</a> in April 2008, modified from the syntax proposed for <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#colors-and-styles">the Canvas element of HTML5</a>. In August of this year, Mozilla announced <a href="/2009/08/08/new-background-rules-in-firefox-3-6/">an implementation slightly modified from that of WebKit</a> would be in the next version of Firefox (3.6).

Since then, however, the <abbr title="CSS Working Group">CSS WG</abbr> have discussed a <a href="http://www.xanthir.com/:4bhipd">different syntax</a>, and <a href="http://www.w3.org/blog/CSS/2009/10/01/resolutions_79">a resolution passed</a> to add this to the <a href="http://www.w3.org/TR/css3-images/">Image Values module</a>. <a href="http://weblogs.mozillazine.org/roc/archives/2009/11/css_gradient_sy.html">Mozilla have decided to implement the new syntax</a>, which is simpler than WebKit's but less flexible.

In this article, which will be split into at least two parts, I'm going to compare the two syntaxes.]]></description>
			<content:encoded><![CDATA[<p>CSS Gradients were <a href="http://webkit.org/blog/175/introducing-css-gradients/">originally proposed by the WebKit team</a> in April 2008, modified from the syntax proposed for <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#colors-and-styles">the Canvas element of HTML5</a>. In August of this year, Mozilla announced that <a href="http://www.broken-links.com/2009/08/08/new-background-rules-in-firefox-3-6/">an implementation slightly modified from that of WebKit</a> would be in the next version of Firefox (3.6).</p>
<p>Since then, however, the <abbr title="CSS Working Group">CSS WG</abbr> have discussed a <a href="http://www.xanthir.com/:4bhipd">different syntax</a>, and <a href="http://www.w3.org/blog/CSS/2009/10/01/resolutions_79">a resolution was passed</a> to add this to the <a href="http://www.w3.org/TR/css3-images/">Image Values module</a>. <a href="http://weblogs.mozillazine.org/roc/archives/2009/11/css_gradient_sy.html">Mozilla have decided to implement the new syntax</a>, which is simpler than WebKit’s but less flexible.</p>
<p>In this article, which will be split into at least two parts, I’m going to compare the two syntaxes.</p>
<p><span id="more-624"></span></p>
<p>Throughout both parts, I will be referring to the following demo page; you’ll need to be using Safari 4, Chrome, or Firefox 3.6beta3+ in order to see it working:</p>
<p><a href="http://www.broken-links.com/tests/gradients/">CSS Gradients comparison: Mozilla &amp; WebKit</a>.</p>
<p>The first and most noticeable difference is that the Mozilla implementation uses two properties – <code>–moz-linear-gradient</code> and <code>–moz-radial-gradient</code> – whereas WebKit use only a single property – <code>–webkit-gradient</code> – with two type values: <code>linear</code> and <code>radial</code>. That should become clearer as I progress.</p>
<p>Please note that I’ve tried to use the simplest syntax possible for all examples, but there may be occasions where I’ve slipped up. Feel free to correct me.</p>
<h2>Linear gradients</h2>
<p>The <a href="https://developer.mozilla.org/en/CSS/-moz-linear-gradient">Mozilla syntax</a> accepts three different properties: start point, angle of direction, and colour stops. <a href="http://developer.apple.com/safari/library/documentation/AppleApplications/Reference/SafariCSSRef/Articles/Functions.html#//apple_ref/doc/uid/TP40007955">WebKit’s</a> also takes three (excluding type: linear, as mentioned previously): start point, end point, and colour stops.</p>
<p>So a simple left-right gradient change (<strong>Linear 1</strong>) between two colours in Mozilla:</p>
<pre>-moz-linear-gradient (left, green, yellow);</pre>
<p>The <em>left</em> value sets the default position to the middle of the left-hand side (<em>0deg</em>, <em>0 50%</em> or <em>left center</em> does the same); the line then goes horizontally out passing from green to yellow in equal proportion.</p>
<p>To get the same pattern in WebKit:</p>
<pre>-webkit-gradient (linear, left center, right center, from(green), to(yellow));</pre>
<p>The start point is at <em>left center</em> (I could use unit values or percentages as Mozilla does, but not an angle), the end point at <em>right center</em>, and it also passes from green to yellow in equal proportion.</p>
<p>We can tweak those values slightly to get a diagonal gradient from the bottom left corner (<strong>Linear 2</strong>); for Mozilla I specify an angle, for WebKit I set new start and end points:</p>
<pre>-moz-linear-gradient(45deg,green,yellow);
-webkit-gradient(linear,left bottom,right top,from(green),to(yellow));</pre>
<p>I’ll tweak those values again to make a bottom-top gradient with an extra colour (<strong>Linear 3</strong>):</p>
<pre>-moz-linear-gradient(90deg,green,yellow,blue);
-webkit-gradient(linear,center bottom,center top,from(green),color-stop(0.5, yellow),to(blue));</pre>
<p>The big difference here is that Mozilla distributes the three colours proportionally, whereas WebKit’s <code>color-stop</code> function requires that I set a stop point — I’ve used <em>0.5</em> here, although I could have used <em>50%</em>. The <code>from</code> and <code>to</code> functions are shorthand for <code>color-stop</code> values <em>0</em> and <em>1</em> (or <em>100%</em>), respectively.</p>
<p>I don’t have to distribute the colours evenly, however; by changing the value in the colour stop I can choose my own ratio. In the final example (<strong>Linear 4</strong>) I’ve set the yellow to begin 25% along the length of the gradient:</p>
<pre>-moz-linear-gradient(90deg,green,yellow 25%,blue);
-webkit-gradient(linear,center bottom,center top,from(green),color-stop(25%, yellow),to(blue));</pre>
<p>For Webkit I only have to update the <code>color-stop</code> value; for Mozilla, I have to specify it.</p>
<h2>Conclusions</h2>
<p>There are a few differences in the syntaxes for linear gradients, but they’re not major; Mozilla use an angle value, where WebKit use a point-to-point system. I’d say Mozilla’s is the easier to grasp purely because of its brevity, but it’s not that important. In the second part of this article I’ll talk about radial gradients, and it’s there that the differences in implementation become more pronounced.</p>
<p><strong>Update:</strong> <a href="http://www.broken-links.com/2009/11/30/css-gradient-syntax-comparison-of-mozilla-and-webkit-part-2/">Part 2 of this article, about Radial Gradients, is now available</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.broken-links.com/2009/11/26/css-gradient-syntax-comparison-of-mozilla-and-webkit/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Using the GeoLocation API</title>
		<link>http://www.broken-links.com/2009/11/11/using-the-geolocation-api/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=using-the-geolocation-api</link>
		<comments>http://www.broken-links.com/2009/11/11/using-the-geolocation-api/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 00:32:42 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[browsers]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[geolocation]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[safari]]></category>

		<guid isPermaLink="false">http://www.broken-links.com/?p=613</guid>
		<description><![CDATA[With the <a href="http://www.brandon-hall.com/workplacelearningtoday/?p=7870">rapid growth of the mobile web</a>, location-aware services are very much in-demand; the <a href="http://dev.w3.org/geo/api/spec-source.html">GeoLocation API</a> was proposed to cater to this need.

Implementation is spotty at the moment; Firefox 3.5 supports it, as does Safari for iPhone (although not on the desktop, <abbr title="as far as I can see">AFAICS</abbr>). But it's so <a href="https://developer.mozilla.org/en/using_geolocation">simple to use</a>, I've no doubt it will be adopted rapidly.]]></description>
			<content:encoded><![CDATA[<p>With the <a href="http://www.brandon-hall.com/workplacelearningtoday/?p=7870">rapid growth of the mobile web</a>, location-aware services are very much in-demand; the <a href="http://dev.w3.org/geo/api/spec-source.html">GeoLocation API</a> was proposed to cater to this need.</p>
<p>Implementation is spotty at the moment; Firefox 3.5 supports it, as does Safari for iPhone (although not on the desktop, <abbr title="as far as I can see">AFAICS</abbr>). But it’s so <a href="https://developer.mozilla.org/en/using_geolocation">simple to use</a>, I’ve no doubt it will be adopted rapidly.</p>
<p><span id="more-613"></span></p>
<p>I’ve put together <a href="http://www.broken-links.com/tests/geolocation/">a small demo of the GeoLocation API</a> in action; it uses data from the Arts Council England website, so visitors from outside of England won’t get any meaningful results from this, I’m afraid. Visitors from England will probably get best results using a mobile device (such as an iPhone).</p>
<p>First, the JavaScript function tests that the browser supports the API:</p>
<pre>var hasGeoLocation = navigator.geolocation ? true : false;
if (hasGeoLocation === true) { ... }</pre>
<p>If so, it requests the current position from the browser using the <code>getCurrentPosition</code> method (the user will have to give permission for this) and passes the result into a function:</p>
<pre>navigator.geolocation.getCurrentPosition(function(position) {
    getJSON(position.coords.latitude,position.coords.longitude);
});</pre>
<p>This result is used in the latitude and longitude attributes of the coords object, which I then use for the rest of my function (using <a href="http://docs.jquery.com/Ajax/jQuery.getJSON">jQuery’s getJSON function</a> to mine microformatted data from <a href="http://www.artscouncil.org.uk/map/">the map page</a> of the Arts Council England website, transforming it using <a href="http://microformatique.com/optimus/">Optimus</a>, then parsing it back into HTML for my demo).</p>
<p>There’s a lot more to this, of course; the API is quite extensive, covering altitude and heading as well as lat/long, and there’s a massive amount of <a href="http://en.wikipedia.org/wiki/Geotagging">geotagged</a> data available (<a href="http://flickr.com/">Flickr</a> photos, for example). Hopefully my demo serves as an example of how easy it is to make the move into the mobile space.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.broken-links.com/2009/11/11/using-the-geolocation-api/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Opera widgets become browser-independent</title>
		<link>http://www.broken-links.com/2009/10/18/opera-widgets-become-browser-independent/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=opera-widgets-become-browser-independent</link>
		<comments>http://www.broken-links.com/2009/10/18/opera-widgets-become-browser-independent/#comments</comments>
		<pubDate>Sun, 18 Oct 2009 22:25:55 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[Asides]]></category>
		<category><![CDATA[browsers]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[opera]]></category>
		<category><![CDATA[widgets]]></category>

		<guid isPermaLink="false">http://www.broken-links.com/?p=611</guid>
		<description><![CDATA[This is a nice idea: Opera have separated their widgets from the desktop browser, allowing them to be run as standalone applications. They are cross-platform and standards compliant. You can download a Labs release to try it for yourself.]]></description>
			<content:encoded><![CDATA[<p>This is a nice idea: <a href="http://labs.opera.com/news/2009/10/15/">Opera have separated their widgets from the desktop browser</a>, allowing them to be run as standalone applications. They are cross-platform and standards compliant. You can download a Labs release to try it for yourself.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.broken-links.com/2009/10/18/opera-widgets-become-browser-independent/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New background rules in Firefox 3.6</title>
		<link>http://www.broken-links.com/2009/08/08/new-background-rules-in-firefox-3-6/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=new-background-rules-in-firefox-3-6</link>
		<comments>http://www.broken-links.com/2009/08/08/new-background-rules-in-firefox-3-6/#comments</comments>
		<pubDate>Sat, 08 Aug 2009 12:49:25 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[browsers]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[background]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[firefox 3.6]]></category>
		<category><![CDATA[webkit]]></category>

		<guid isPermaLink="false">http://www.broken-links.com/?p=497</guid>
		<description><![CDATA[The latest alpha release of Firefox 3.6 (3.6a1) contains some new rules for providing backgrounds to elements: multiple background images, background-size, and an implementation of the Webkit gradient proposal (modified from the original - more on that later).]]></description>
			<content:encoded><![CDATA[<p>The <a href="https://developer.mozilla.org/devnews/index.php/2009/08/07/firefox-3-6-alpha-1-now-available-for-download/">latest alpha release of Firefox 3.6 (3.6a1)</a> contains some new rules for providing backgrounds to elements: multiple background images, <a href="https://developer.mozilla.org/en/CSS/-moz-background-size">background-size</a>, and <a href="https://developer.mozilla.org/en/CSS/Gradients">an implementation of the Webkit gradient proposal</a> (modified from <a href="http://webkit.org/blog/175/introducing-css-gradients/">the original</a> — more on that later).</p>
<p>I’ve put together <a href="http://www.broken-links.com/tests/backgrounds/">a very rough demo of what you can do with these new rules</a>; you’ll require a recent build of Firefox 3.6 or Webkit to view it. Try resizing the window to different dimensions, and see how it changes.</p>
<p>Here’s an explanation of how I did it:</p>
<p><span id="more-497"></span></p>
<p>The first div has a radial gradient applied to it using the <code>background-image</code> property:</p>
<pre>background-image: -moz-radial-gradient(center, 10px, center, 480px, from(#aedae5), to(white));
background-repeat: no-repeat;
</pre>
<p>The positional values (center and pixel values) instruct where to start the radius from, and where to end it; in my example, I’m starting 10px from the center and radiating out to 480px. The second values (from, to) set the start and end colours for the gradient. All of these declarations accept many more values than I’ve shown here.</p>
<p>Mozilla’s implementation differs from the Webkit proposal in a few significant ways, the most obvious being that Webkit uses a single rule (<code>–webkit-gradient</code>) with a type value (linear or radial), whereas Mozilla use two rules (<code>–moz-linear-gradient</code> and <code>–moz-radial-gradient</code>). Mozilla’s implementation also tiles unless <code>background-repeat</code> is set to <code>no-repeat</code>.</p>
<p>The <a href="https://developer.mozilla.org/en/CSS/Gradients">Mozilla Dev Center page</a> explains the differences in more detail. Having just used both in building this demo, I have to say that the Mozilla implementation is more logical a little easier to learn.</p>
<p>The second part of my demo uses multiple backgrounds on the internal div to display <a href="http://www.foxkeh.com/">Foxkeh</a> behind the cut-out letters:</p>
<pre>background:
url('images/ff3_6.png') no-repeat 50% 50%,
url('images/foxkeh.png') no-repeat 50% 50%;</pre>
<p>The stack is calculated in descending order, so the first value takes precedence over the second.</p>
<p>Finally, to make sure that my letters always fill the screen, I’ve used background-size to stretch the image over its containing element:</p>
<pre>-moz-background-size: 100% 100%, auto;</pre>
<p>I’ve used two comma-separated values to match the multiple backgrounds above; the first value stretches the background image to 100% of its container, the second keeps Foxkeh at his natural size.</p>
<p>If you plan to use these declarations you may also be interested in <a href="https://developer.mozilla.org/en/CSS/image-rendering">image rendering</a>; however, that’s beyond the scope of this post. </p>
<p>It’s good to see Mozilla being more experimental, and nice for us to have new declarations to experiment with. I hope that Mozilla and Webkit agree on a common implementation of gradients, so that the proposal becomes accepted more quickly.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.broken-links.com/2009/08/08/new-background-rules-in-firefox-3-6/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>background-size implemented in Firefox 3.6</title>
		<link>http://www.broken-links.com/2009/08/05/background-size-implemented-in-firefox-3-6/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=background-size-implemented-in-firefox-3-6</link>
		<comments>http://www.broken-links.com/2009/08/05/background-size-implemented-in-firefox-3-6/#comments</comments>
		<pubDate>Tue, 04 Aug 2009 23:05:49 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[browsers]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[firefox]]></category>

		<guid isPermaLink="false">http://www.broken-links.com/?p=492</guid>
		<description><![CDATA[Firefox 3.6 has become the latest browser to support the CSS3 <code>background-size</code> property (although the first to do so according to the latest W3C spec.).]]></description>
			<content:encoded><![CDATA[<p><a href="https://developer.mozilla.org/web-tech/2009/08/04/background-images-no-longer-restricted-to-original-size-explore-the-space-with-background-size/">Firefox 3.6 has become the latest browser to support the CSS3 <code>background-size</code> property</a> (although the first to do so according to the latest W3C spec.).</p>
<p>Using it is pretty simple:</p>
<pre>div {
background-image: url('image.png');
-moz-background-size: 80%;
}</pre>
<p>This, along with <a href="http://ajaxian.com/archives/firefox-support-for-css3-multiple-backgrounds">multiple <code>background-image</code>s</a>, is going to go a long way towards cleaning up mark-up and prettifying the web.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.broken-links.com/2009/08/05/background-size-implemented-in-firefox-3-6/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
