<?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>TimKadlec.com &#187; (x)html</title>
	<atom:link href="http://timkadlec.com/tag/xhtml-2/feed/" rel="self" type="application/rss+xml" />
	<link>http://timkadlec.com</link>
	<description>A Wisconsin based web developer writing about the web.</description>
	<lastBuildDate>Tue, 15 May 2012 16:56:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Building a Stronger DOM</title>
		<link>http://timkadlec.com/2009/05/building-a-stronger-dom/</link>
		<comments>http://timkadlec.com/2009/05/building-a-stronger-dom/#comments</comments>
		<pubDate>Thu, 07 May 2009 03:00:00 +0000</pubDate>
		<dc:creator>Tim Kadlec</dc:creator>
				<category><![CDATA[(X)HTML]]></category>
		<category><![CDATA[(x)html]]></category>
		<category><![CDATA[semantics]]></category>

		<guid isPermaLink="false">http://localhost/1969/12/building-a-stronger-dom/</guid>
		<description><![CDATA[In Nate Koechley's excellent talk on Frontend Engineering, he talks about the importance of building a "stronger DOM". By marking up your site with meaningful elements and attributes, you give your markup more value and provide a richer experience for both users and machines.]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://nate.koechley.com/blog/">Nate Koechley&#8217;s</a> excellent talk on <a href="http://video.yahoo.com/watch/4671445/12486762">Frontend Engineering</a>, he talks about the importance of building a &#8220;stronger DOM&#8221;. By marking up your site with meaningful elements and attributes, you give your markup more value and provide a richer experience for both users and machines.</p>
<p>In addition, a strong DOM provides you with numerous attributes and elements that you can make use of to style the content to your hearts desire. This gives you much more power and control with your CSS, and helps to greatly decrease your usage of extraneous divs and classes</p>
<p>A very quick way to improve your markup skills, and therefore the value of your content, is to expand your knowledge of HTML elements, and start making use of a few you might not have been aware of.</p>
<h2>
<fieldset> and<br />
<legend></legend>
</fieldset>
</h2>
<p>The fieldset element is used to group related controls and labels within a form. They are a great way to help make your form easier to understand, and more accessible for speech-navigated user agents.</p>
<p>It should be used in conjunction with the legend element to provide an even richer and more usable experience. The legend element basically defines a caption for the fieldset. Here&#8217;s an example of how you could use these elements in your markup:</p>
<ol class="code">
<li>
<form method="post"></form>
</li>
<li class="tab1">
<fieldset></fieldset>
</li>
<li class="tab2">Team Captain</li>
<li class="tab2"><label for="captain">Name</label></li>
<li class="tab2">
<input id="captain" name="captain" type="text" /></li>
<li class="tab1">
<fieldset></fieldset>
</li>
<li class="tab2">Player #2</li>
<li class="tab2"><label for="player2">Name</label></li>
<li class="tab2">
<input id="player2" name="player2" type="text" /></li>
<li></li>
</ol>
<h2><q></q></h2>
<p>An often forgot element that you can start using immediately in your text is the q element. The q element is very similar to the blockquote element, but should be used in a different context. The blockquote element is meant to be used for longer, <em>block-level</em> quotes. The q element, on the other hand should be used for short quotes.</p>
<p>All major browsers, other than IE6 and IE7, will automatically insert quotation marks around the content within the q element, according to the HTML spec. There&#8217;s a few ways to work around this, but my favorite solution is the one proposed by Stacy Cordoni in an <a href="http://www.alistapart.com/articles/qtag/">A List Apart article</a> from 2006. Her solution is to remove the quotes from around the q element using the :before and :after pseudo-classes to even the playing field. Then, with each of the major browsers not rendering quotes, you can insert them directly into your markup, ensuring that all browsers render your quote the same.</p>
<ul class="code">
<li>&#8220;<q>Remember that drover, the one I shot in the mouth so&#8217;s the teeth come out the back of his head?</q>&#8220;, asked Munny.</li>
</ul>
<h2><cite></cite></h2>
<p>The cite element is used to identify a reference or citation to another source, like a book or another website. By default, each of the major browsers render the cite element in italics. Making use of our q element example, adding the cite element would give us something like this:</p>
<ul class="code">
<li>&#8220;<q>Remember that drover, the one I shot in the mouth so&#8217;s the teeth come out the back of his head?</q>&#8220;, asked <cite>Munny</cite>.</li>
</ul>
<h2><dfn></dfn></h2>
<p><dfn>The dfn element is used to markup the defining instance of a word or phrase. It&#8217;s important to note that it is not intended to markup the actual definition itself, but instead the word or phrase being defined. Most major browsers will render the content within the dfn element in italics, though of course you can alter that as you wish with CSS.</p>
<ul class="code">
<li>The <dfn>dfn element</dfn> is used to markup the defining instance of a word or phrase.</li>
</ul>
<h2><ins> and <del></del></ins></h2>
<p>Here&#8217;s one for anyone who writes any sort of articles online. You can use the ins and del elements to identify content that has been either inserted or deleted since the content&#8217;s publication. The ins element, by default, is underlined, and the del element, by default, is striked through.</p>
<ul class="code">
<li>SXSW&#8217;s parties are a great time to <del>booze it up with</del> <ins>mingle with</ins> fellow developers.</li>
</ul>
<h2>
<address></address>
</h2>
<p>The address element is slightly misleading. One would think you would use it to mark up a physical address, but that&#8217;s not necessarily the case. The address element is actually intended to contain the contact point for the document containing it. While this certainly could contain a physical address, it doesn&#8217;t have to. It could house any sort of contact information provided that it is contact information for the author and/or owner of the document in question.</p>
<p>For example, I could use the address element to provide my contact information since I am the owner of this article, like so:</p>
<ul class="code">
<li>
<address><a href="mailto:tim@timkadlec.com">tim@timkadlec.com</a></address>
</li>
</ul>
<p>By default, the address element is rendered in italics in each of the major browsers.</p>
<h2>See For Yourself</h2>
<p>If you&#8217;re interested, I <a href="underused.htm">put up a page</a> with examples of each of the elements above. I did not apply any CSS, so you can see how each element is rendered by default in different browsers.</p>
<p></dfn></p>
]]></content:encoded>
			<wfw:commentRss>http://timkadlec.com/2009/05/building-a-stronger-dom/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>The Canvas Element: Starting to Draw</title>
		<link>http://timkadlec.com/2008/09/the-canvas-element-starting-to-draw/</link>
		<comments>http://timkadlec.com/2008/09/the-canvas-element-starting-to-draw/#comments</comments>
		<pubDate>Fri, 19 Sep 2008 03:00:00 +0000</pubDate>
		<dc:creator>Tim Kadlec</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[(x)html]]></category>
		<category><![CDATA[html5]]></category>

		<guid isPermaLink="false">http://localhost/1969/12/the-canvas-element-starting-to-draw/</guid>
		<description><![CDATA[Last time around, we took a general look at the canvas element and how it is supported (or not) in various browsers. This time, we'll start to go into the element in a bit more detail and start to look at some the things we can do with it.]]></description>
			<content:encoded><![CDATA[<p>Last <a href="post.asp?q=73">time around</a>, we took a general look at the canvas element and how it is supported (or not) in various browsers. This time, we&#8217;ll start to go into the element in a bit more detail and start to look at some the things we can do with it.</p>
<h2>A Quick Look at Attributes</h2>
<p>We&#8217;ve already seen how to set up the canvas element in HTML:</p>
<p>You&#8217;ve probably noticed that we&#8217;ve included an id attribute on our canvas element to make it easier for us to access the element in our Javascript. You can also apply other standard attributes like class, title or tabindex. Two other attributes, height and width, will also be used fairly regularly.</p>
<p>You can define the height and width as attributes in the canvas element, or you can use CSS to define the dimensions of your element. If you use CSS, however, your canvas will scale to meet the dimensions you define instead of simply resizing the area. Neither height nor width are necessary, however. If you choose to not define the size of the canvas element, then it defaults to a size of 300 pixels wide by 150 pixels high.</p>
<h2>Roll Up Your Sleeves&#8230;</h2>
<p>All of this so far has been pretty easy&#8230;but also boring. The canvas element&#8217;s real power, of course, is the ability to use Javascript to manipulate it. To do so, we have to get a rendering context using the getContext() function. The rendering context is what allows us to actually manipulate the content in the canvas element. The function is straight forward and easy to use:</p>
<ol class="code">
<li>var canvas = document.getElementById(&#8216;canvas&#8217;);</li>
<li>var context = canvas.getContext(&#8217;2d&#8217;);</li>
</ol>
<p>Currently, &#8220;2d&#8221; is the only defined context that we can obtain. In the future, it is not unreasonable to expect to see that expand and include support for a three dimensional drawing context. Of course in a real-world setting you&#8217;ll want to check to make sure the browser supports the getContext method in the first place. The canvas element is still relatively new and there will be a fair amount of browsers that will not support it.</p>
<h2>The One and Only</h2>
<p>Now that we have a rendering context, let&#8217;s make use of it by starting to draw something to the canvas. The canvas element only natively supports one shape and that is the rectangle. Don&#8217;t panic&#8230;.you&#8217;ll see later that there are plenty of methods available for us to create everything from a basic circle to very complex abstract shapes.</p>
<p>For now though, we&#8217;ll keep it simple and just make a rectangle. We have three functions that are available to use for this: fillRect(), strokeRect(), and clearRect(). The functions do pretty much exactly what you would think based on their names. fillRect() draws a filled rectangle; strokeRect() draws a rectangle with border, or stroke, around it; and clearRect() clears the area and makes a fully transparent rectangle. To make it even more simple, each of the functions takes the exact same parameters. Let&#8217;s take for example the following line of code:</p>
<ul class="code">
<li>context.fillRect(0,0,50,75);</li>
</ul>
<p>As you can see, the function takes four parameters. The first two define the starting point of the shape, the x and y coordinates. Thankfully the coordinates follow common sense. The origin or (0,0) is the top left of the canvas element. So (0,10) would be at the top and 10 pixels from the left.</p>
<p>The next two parameters are the width and height of the canvas element. In this case, I made a rectangle that is 50 pixels wide and 75 pixels high. So the result of the above line of code is a 50 pixel by 75 pixel, filled rectangle in the top left corner of the canvas element. To get a good idea of the results of each of the rectangle functions, we&#8217;ll use the following code (we&#8217;ve also set the height and width attributes on our canvas element to 125 pixels each) :</p>
<ol class="code">
<li>context.fillRect(0,0,50,50);</li>
<li>context.clearRect(25,25,50,50);</li>
<li>context.fillRect(50,50,50,50);</li>
<li>context.strokeRect(75,75,50,50);</li>
</ol>
<p>The result, <a href="canvas.asp">as you can see here</a>, is four overlapping rectangles. Remember, you&#8217;ll need Firefox (1.5+), Safari, or Opera (9+) to view it. As you can see, the clear rectangle clears out the area it covers. The stroke rectangle, on the other hand, doesn&#8217;t clear out the area, so you can see the filled rectangle through it.</p>
<h2>Next Time</h2>
<p>Next time around, we&#8217;ll start to look at some of the other functions available, and how we can use those functions to start making a variety of shapes&#8230;not just simple rectangles. To wet your appetite a bit in the meantime, have a look at <a href="http://blog.nihilogic.dk/2008/09/sandbag-text-wrapping-with-canvas.html">another great example</a> of how the canvas element can be used.</p>
]]></content:encoded>
			<wfw:commentRss>http://timkadlec.com/2008/09/the-canvas-element-starting-to-draw/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting Started with the Canvas Element</title>
		<link>http://timkadlec.com/2008/09/getting-started-with-the-canvas-element/</link>
		<comments>http://timkadlec.com/2008/09/getting-started-with-the-canvas-element/#comments</comments>
		<pubDate>Thu, 11 Sep 2008 03:00:00 +0000</pubDate>
		<dc:creator>Tim Kadlec</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[(x)html]]></category>
		<category><![CDATA[html5]]></category>

		<guid isPermaLink="false">http://localhost/1969/12/getting-started-with-the-canvas-element/</guid>
		<description><![CDATA[There's a lot of really exciting and interesting features arriving just around the corner in the world of web development. One of the new features that is receiving a lot of attention, and for good reason, is the new canvas element.]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s a lot of really exciting and interesting features arriving just around the corner in the world of web development. One of the new features that is receiving a lot of attention, and for good reason, is the new canvas element. The canvas element offers a lot of power to web developers, but can take a bit for some people to get comfortable with. So, I&#8217;m going to run a series of posts introducing this powerful new feature, and showing some of the ways it can be utilized.</p>
<h2>What Is It, and Who Supports It?</h2>
<p>The canvas element was originally implemented in Safari, and then became standardized in the HTML5 specification. The element allows developers to dynamically draw onto a blank &#8216;canvas&#8217; in a website. Thankfully, you don&#8217;t have to wait to play around with this element. Currently, you can find support for it in Firefox (version 1.5 and newer), Safari, or Opera (version 9 and newer). In addition, you can twist IE&#8217;s arm a bit thanks to Google and Mozilla. Google has created <a href="http://excanvas.sourceforge.net/">ExplorerCanvas</a>, a script that allows your canvas scripts to work in IE. For more intensive applications, Mozilla created has created an <a href="http://arstechnica.com/news.ars/post/20080819-mozilla-drags-ie-into-the-future-with-canvas-element-plugin.html">ActiveX plugin</a> for IE to bring canvas support to the widely used browser. So, there&#8217;s little reason why you can&#8217;t start using it today&#8230;.Google Maps does!</p>
<p>Unfortunately, there is some discrepancy in the way browsers support the canvas element right now. For example, in Safari, the canvas tag works a lot like the img tag&#8230;it doesn&#8217;t require a closing tag. In Safari, you can close the element like so:</p>
<ul class="code"></ul>
<p>In Firefox, however, the canvas element requires a closing tag:</p>
<ul class="code"></ul>
<p>The problem comes in with alternate content. In Firefox, we can simply throw our alternate content in between the opening and closing canvas tags. If the browser doesn&#8217;t support the canvas element, then the alternate content displays. In Safari, the content displays regardless. There are a few ways you can hack around this however, including this one presented by <a href="http://mattsnider.com/languages/javascript/intro-to-html-canvas-tag/">Matt Snider</a>.</p>
<h2>Why It&#8217;s Cool</h2>
<p>The canvas element is not meant for static images&#8230;though it can certainly be used to do that. The real power of it comes when we make use of Javascript to manipulate the canvas element and create dynamic visualizations like data charts and graphs, interactive diagrams and games. In fact, there are a couple impressive Javascript game recreations that have already been developed that make use of the canvas element. You can already play <a href="http://www.nihilogic.dk/labs/mariokart/">Mario Kart</a>, <a href="http://blog.nihilogic.dk/2008/04/super-mario-in-14kb-javascript.html">Super Mario</a>, and an incredibly addicting game called <a href="http://www.gamesforthebrain.com/game/oooze/">Ooze</a>.</p>
<p>The canvas element is a great example of where implementation precedes standardization. Safari implemented it, then Firefox and Opera caught on, and now the <abbr title="Web Hypertext Application Technology Working Group">WHAT-WG</abbr> is incorporating it into the HTML5 specification. Once implemented, it provides us with a standardized, cross-browser means to dynamically display data and react to user events in a way that previously required Flash.</p>
<h2>What&#8217;s Coming Up</h2>
<p>Next time around, we&#8217;ll start to look at the canvas element in more detail including the attributes available. We&#8217;ll also start diving into some Javascript and some of the methods provided by the DOM to interact with the canvas element.</p>
]]></content:encoded>
			<wfw:commentRss>http://timkadlec.com/2008/09/getting-started-with-the-canvas-element/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

