<?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>Tudor Barbu&#039;s professional blog &#187; xhtml</title>
	<atom:link href="http://blog.motane.lu/tag/xhtml/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.motane.lu</link>
	<description>Ramblings about software development</description>
	<lastBuildDate>Thu, 02 Feb 2012 17:38:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Semantics &#8211; input type=&#8221;submit&#8221; vs. button</title>
		<link>http://blog.motane.lu/2009/03/06/semantics-input-typesubmit-vs-button/</link>
		<comments>http://blog.motane.lu/2009/03/06/semantics-input-typesubmit-vs-button/#comments</comments>
		<pubDate>Fri, 06 Mar 2009 21:03:54 +0000</pubDate>
		<dc:creator>Tudor</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[semantic web]]></category>
		<category><![CDATA[versus]]></category>
		<category><![CDATA[w3c]]></category>
		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://blog.motane.lu/?p=514</guid>
		<description><![CDATA[What&#8217;s the difference between: &#8230;and&#8230; Apparently none. Both snippets look and act exactly the same way. And yet, there is a more subtle difference. The difference lies in the semantics and in the meaning of the two types of buttons. A &#60;button&#62; tag displays a button, that you can click with your mouse and can [...]]]></description>
			<content:encoded><![CDATA[<p>What&#8217;s the difference between:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;form action=&quot;/foo&quot; method=&quot;post&quot;&gt;
    &lt;!-- other form fields --&gt;
    &lt;input type=&quot;submit&quot; value=&quot;Send data&quot; /&gt;
&lt;/form&gt;
</pre>
<p>&#8230;and&#8230;</p>
<pre class="brush: xml; title: ; notranslate">
&lt;form action=&quot;/foo&quot; method=&quot;post&quot;&gt;
    &lt;!-- other form fields --&gt;
    &lt;button type=&quot;submit&quot;&gt;
        Send data
    &lt;/button&gt;
&lt;/form&gt;
</pre>
<p>Apparently none. Both snippets look and act exactly the same way. And yet, there is a more subtle difference. The difference lies in the semantics and in the meaning of the two types of buttons. A &lt;button&gt; tag displays a button, that you can click with your mouse and can be placed almost anywhere on a page. That&#8217;s all. It doesn&#8217;t have a purpose. </p>
<p>An &lt;input type=&#8221;submit&#8221; &gt; on the other hand does a lot more. It&#8217;s a form element &#8211; can only appear in a form &#8211; and it has meaning attached to it. When you submit a form by clicking on such an button, the value of the button is being sent along with the values of all the other form elements to the server. </p>
<pre class="brush: xml; title: ; notranslate">
&lt;form action=&quot;/foo&quot; method=&quot;post&quot;&gt;
    &lt;input type=&quot;checkbox&quot; name=&quot;item[]&quot; value=&quot;1&quot; id=&quot;item_1&quot; /&gt; &lt;label for=&quot;item_1&quot;&gt;First item&lt;/label&gt;
    &lt;input type=&quot;checkbox&quot; name=&quot;item[]&quot; value=&quot;2&quot; id=&quot;item_2&quot; /&gt; &lt;label for=&quot;item_2&quot;&gt;Second item&lt;/label&gt;
    &lt;input type=&quot;checkbox&quot; name=&quot;item[]&quot; value=&quot;3&quot; id=&quot;item_3&quot; /&gt; &lt;label for=&quot;item_3&quot;&gt;Third item&lt;/label&gt;
    With selected: &lt;input type=&quot;submit&quot; name=&quot;delete&quot; value=&quot;Delete&quot; /&gt; &lt;input type=&quot;submit&quot; name=&quot;archive&quot; value=&quot;Move to archive&quot; /&gt;
&lt;/form&gt;
</pre>
<p>In this case it matters on which button the user clicks, so an input type=&#8221;submit&#8221; tag is the best choice. But when you have something like:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;form action=&quot;/foo&quot; method=&quot;post&quot;&gt;
    &lt;input type=&quot;text&quot; name=&quot;email&quot; /&gt;
    &lt;button type=&quot;submit&quot;&gt;
        Subscribe to newsletter
    &lt;/button&gt;
&lt;/form&gt;
</pre>
<p>&#8230;it doesn&#8217;t! So here the button tag is best suited.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.motane.lu/2009/03/06/semantics-input-typesubmit-vs-button/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Semantic FAQs</title>
		<link>http://blog.motane.lu/2009/01/26/semantic-faqs/</link>
		<comments>http://blog.motane.lu/2009/01/26/semantic-faqs/#comments</comments>
		<pubDate>Mon, 26 Jan 2009 19:47:42 +0000</pubDate>
		<dc:creator>Tudor</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[semantic web]]></category>
		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://blog.motane.lu/?p=110</guid>
		<description><![CDATA[You know the saying it&#8217;s funny because is true? Well it also applies to software development. This drawing it&#8217;s funny because is true. And when &#8211; not if, when &#8211; your application will start looking like that, it&#8217;s obvious that you&#8217;ll need a FAQ section. Usually, people use tables or other types of markup for [...]]]></description>
			<content:encoded><![CDATA[<p>You know the saying <em>it&#8217;s funny because is true</em>? Well it also applies to software development. This drawing <a href="http://stuffthathappens.com/blog/2008/03/05/simplicity/" title="Simplicity" class="outgoing">it&#8217;s funny because is true</a>. And when &#8211; not if, when &#8211; your application will start looking like that, it&#8217;s obvious that you&#8217;ll need a <acronym title="Frequently Asked Questions">FAQ</acronym> section. </p>
<p>Usually, people use tables or other types of markup for setting up the FAQ page, but the proper way to code it is the long forgotten <a href="http://www.w3.org/TR/2004/WD-xhtml2-20040722/mod-list.html#sec_11.1.">definition list</a>. When it comes to semantics, this is the perfect choice. The questions in the FAQ represent the definition terms and their answers the definition data.</p>
<p>The proper xhtml code for the FAQ page should look like this&#8230;</p>
<pre class="brush: xml; title: ; notranslate">
&lt;dl&gt;
    &lt;dt&gt;How do I...?&lt;/dt&gt;
    &lt;dd&gt;Just click the ... button!&lt;/dd&gt;
    &lt;dt&gt;Are your sure?&lt;/dt&gt;
    &lt;dd&gt;Positive!&lt;/dd&gt;
&lt;/dl&gt;
</pre>
<p>&#8230;of course, with more relevant data.<span id="more-110"></span></p>
<h2><span>Improved FAQ</span></h2>
<p>If you have a lot of questions, displaying them all to the user at once isn&#8217;t always such a good idea. If you have many items in your list, you can hide all the answers an only display them when the user clicks on the associated question. The proper way to do this is to hide the <strong>dd</strong>s with Javascript, because if you hide them using CSS and display:none and the user turns off js in the browser, he will only be able to stare with increasing frustration at a list of questions with no visible answers. </p>
<p>Here are two javascript implementations, with two of the most popular javascript frameworks at this moment: <a href="http://www.prototypejs.org/" title="Prototype Javascript framework" class="outgoing">prototype</a> and <a href="http://www.jquery.com" title="jQuery Javascript library" class="outgoing">jQuery</a> that convert a regular definition list into a clickable one in a unobtrusive manner that degrades gracefully.</p>
<p>Prototype implementation (<a href="http://demos.motane.lu/semantic-faqs/semantic-faqs-prototype.html" title="working example with prototype">see working example</a>):</p>
<pre class="brush: jscript; title: ; notranslate">
Event.observe(
    window,
    'load',
    function() {
        $$( '.faq dd' ).each(
            function( item ) {
                item.hide();
            }
        );

        $$( '.faq dt' ).each(
            function( item ) {
                item.observe(
                    'click',
                    function( event ) {
                        Event.element( event ).next().toggle();
                    }
                );
            }
        );
    },
    true
);
</pre>
<p>jQuery implementation (<a href="http://demos.motane.lu/semantic-faqs/semantic-faqs-jquery.html" title="working example with jQuery">see working example</a>):</p>
<pre class="brush: jscript; title: ; notranslate">
$( document ).ready(
    function() {
        $( '.faq dd' ).hide();
        $( '.faq dt' ).toggle(
            function() {
                $( this ).next().show();
            },
            function() {
                $( this ).next().hide();
            }
        );
    }
);
</pre>
<p>Another good idea is to let the user know that the definition terms are &#8220;clickable&#8221;, by adding the following rule to your CSS file: </p>
<pre class="brush: css; title: ; notranslate">
.faq dt {
    cursor: hand;
}
</pre>
<p>Questions? <img src='http://blog.motane.lu/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.motane.lu/2009/01/26/semantic-faqs/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Labels and accessibility</title>
		<link>http://blog.motane.lu/2008/12/20/labels-and-accessibility/</link>
		<comments>http://blog.motane.lu/2008/12/20/labels-and-accessibility/#comments</comments>
		<pubDate>Sat, 20 Dec 2008 22:50:31 +0000</pubDate>
		<dc:creator>Tudor</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[accesibility]]></category>
		<category><![CDATA[standards]]></category>
		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://blog.motane.lu/?p=31</guid>
		<description><![CDATA[Some time ago, I&#8217;ve stumbled upon some specifications about the proper use of the label tag on webpages. And it seems that labels are a must if you want to make your page accessible to people with disabilities or if you just want to pass the Cynthia says validation and brag about it. Proper use [...]]]></description>
			<content:encoded><![CDATA[<p>Some time ago, I&#8217;ve stumbled upon some specifications about the proper use of the label tag on webpages. And it seems that labels are a must if you want to make your page accessible to people with disabilities or if you just want to pass the <a class="outgoing" title="Cynthia Says Portal" href="http://www.contentquality.com/">Cynthia says</a> validation and brag about it.<span id="more-31"></span></p>
<h2><span>Proper use of labels</span></h2>
<p>You can assign labels to text inputs or textareas by specifying the &#8220;for&#8221; attribute. Like so:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;label for=&quot;username&quot;&gt;Enter your username&lt;/label&gt;
&lt;input type=&quot;text&quot; name=&quot;username&quot; id=&quot;username&quot;&gt;
</pre>
<p>This will help screen readers and other software designed to help impaired people surf the web to correctly interpret your code and make the right associations between labels and textfields. For instance, the following piece of code displays a table row with some form tags in it:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;tr&gt;
	&lt;td&gt;
		Enter your username
	&lt;/td&gt;
	&lt;td&gt;
		&lt;input type=&quot;text&quot; name=&quot;username&quot; id=&quot;username&quot; /&gt;
	&lt;/td&gt;
&lt;/tr&gt;
</pre>
<p>For a normal visitor, this is very simple to understand because the &#8220;Enter your username&#8221; text and the username textfield are on the same line. But for a blind person that uses a screen reader, this will not be displayed at all. And the screen reader must decide witch text goes with what textfield.</p>
<p>On this example, I believe that most screen readers will make the right connection between text and textfield, but if the html code becomes a little more complicated (ie. more text or other tags) I sure that the screen reader will fail to make the right assumptions. But the use of labels can fix that.</p>
<h2><span>Label&#8217;s accesskey</span></h2>
<p>If you want to give your forms a cool &#8220;web2.0 style&#8221; functionality, you can specify the accesskey attribute for your labels. For example you can do something like:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;label for=&quot;username&quot; accesskey=&quot;u&quot;&gt;Enter your &lt;strong&gt;u&lt;/strong&gt;sername&lt;/label&gt;
&lt;input type=&quot;text&quot; name=&quot;username&quot; id=&quot;username&quot; /&gt;
</pre>
<p>&#8230;and when the user presses CTRL/ALT + u (depending on the browser) he&#8217;ll be taken directly to that textfield. Pretty neat.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.motane.lu/2008/12/20/labels-and-accessibility/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

