<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>css thoughts</title>
    <link rel="alternate" type="text/html" href="http://gabriel.prat.name/css/" />
    <link rel="self" type="application/atom+xml" href="http://gabriel.prat.name/css/atom.xml" />
    <id>tag:gabriel.prat.name,2009-10-12:/css/1</id>
    <updated>2009-11-08T20:02:15Z</updated>
    <subtitle>xhtml and css solutions to create standard, semantic and simple layouts and widgets for your web pages.</subtitle>
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type 5.12</generator>

<entry>
    <title>Nice css/xhtml accessible tabbed navigation</title>
    <link rel="alternate" type="text/html" href="http://gabriel.prat.name/css/2009/11/nice-css-xhtml-accessible-tabbed-navigation.html" />
    <id>tag:gabriel.prat.name,2009:/css//1.3</id>

    <published>2009-11-08T17:18:14Z</published>
    <updated>2009-11-08T20:02:15Z</updated>

    <summary> Why is it better than other tabbed navigations? The tab size change to fit its text Tabs keep the elements&apos; inline display so it can be used in a line of text As they are not a block elements,...</summary>
    <author>
        <name>Gabri</name>
        
    </author>
    
        <category term="accessibility" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="navigation" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="widgets" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en-US" xml:base="http://gabriel.prat.name/css/">
        <![CDATA[ <h3>Why is it better than other tabbed navigations?</h3>
<ul>
<li>The tab size change to fit its text</li>
<li>Tabs keep the elements' inline display so it can be used in a line of text</li>
<li>As they are not a block elements, no <code>float</code> is needed so they can be centered or used inside a floated container</li>
<li>They have a pure <abbr title="Cascading Style Sheets">CSS</abbr> [<a shape="rect" href="#def-CSS">CSS</a>] rollover and pushed effects (except in IE6)</li>
<li>They use only one image to improve download speed and avoid delays showing the rollover or pushed effects</li>
<li>They have simple semantic valid XHTML strict markup and valid <abbr title="Cascading Style Sheets">CSS</abbr> 2.1 without any hacks or tricks</li>
<li>They set <abbr title="Accessible Rich Internet Applications">WAI-ARIA</abbr> [<a shape="rect" href="#def-ARIA">ARIA</a>] <code>role</code> attributes on the elements to help <a href="http://www.w3.org/TR/2009/WD-wai-aria-20090224/#def_useragent">user agents</a> and <a href="http://www.w3.org/TR/2009/WD-wai-aria-20090224/#def_at">assistive technology</a> understand what the markup semantics.</li>
<li>Tested with IE5, IE5.5, IE6, IE7, IE8, FF1, FF2, FF3, Opera
9, Opera 10, Konkeror 4.2, Epiphany 2.2, Safari 3, Safari 4, Chrome 3 and Chrome
4. Available versions for Windows and Ubuntu linux.</li>
</ul>
<h3>Doctype</h3>
<p>In the current WAI-ARIA Best Practices [<a shape="rect" href="#def-ARIA-PRACTICES">ARIA-PRACTICES</a>] we can read:
</p><blockquote>
WAI-ARIA markup is currently not included in (X)HTML. The W3C WAI PF working group will be creating DTDs for XHTML 1.0 and HTML 4.01 for those wishing to validate their markup with WAI-ARIA embedded into these host languages.
</blockquote>
<p>But I wanted my documents to validate using the <a href="http://validator.w3.org/">w3c validator</a> so I decided to host a copy of the <a href="http://www.w3.org/TR/2009/WD-wai-aria-20090224/#xhtml_dtd">provisional XHTML+ARIA DTD</a> and set it as the doctype.</p>
<pre>&lt;!DOCTYPE html PUBLIC "Accessible Adaptive Applications//EN" 
    "http://gabriel.prat.name/css.back/xhtml-aria.dtd"&gt;
</pre>
<p>Basically the document is <abbr title="Extensible Hypertext Markup Language">XHTML</abbr> 1.1 plus an extension module [<a shape="rect" href="#def-XHTMLMOD">XHTMLMOD</a>] with all the <abbr title="Accessible Rich Internet Applications">WAI-ARIA</abbr> attributes.
</p>
<p>If you don't care about <abbr title="Extensible Hypertext Markup Language">XHTML</abbr> validation, you could use a normal <abbr title="Extensible Hypertext Markup Language">XHTML</abbr> 1.0 doctype instead.</p>

<h3>Markup</h3>
<p>The markup consists of an <code>ul</code> for the tab list containing a link in each child <code>li</code>. The tab panel consists of a <code>div</code> with two sections: a header and a footer. The header consists of another <code>div</code> (necessary to display the rounded corners) with a child <code>h2</code> which could easily be replaced with another level heading if needed. The body of the tab panel is just another <code>div</code> that also helps displaying the rounded corners of the panel.</p>
<p>No element is floated, the list elements have <code>display:inline</code> to display them one next to another, so they can be centered, floated or used within a line of text. </p>
<p>In the example the markup of the navigation tabs is below the main content of the page to preserve the logical information structure of the page. Showing the main content in the first place to the user (and to the search engines) to give it more importance than the navigation links. To position them they are both included in a <code>div</code> with <code>id="content"</code>.</p>

<pre>&lt;div id="content"&gt;
&lt;div class="tabpanel" role="tabpanel main"&gt;
        &lt;div class="hd"&gt;
                &lt;h2&gt;This is the tab contents title&lt;/h2&gt;
        &lt;/div&gt;
        &lt;div class="bd"&gt;
		&lt;p&gt;Some paragraphs of text&lt;/p&gt;
	&lt;/div&gt;
&lt;/div&gt;
&lt;h2 class="hide" id="main-nav-label"&gt;Main navigation&lt;/h2&gt;
&lt;ul class="tablist" role="navigation tablist" aria-labelledby="main-nav-label"&gt;
        &lt;li role="tab" tabindex="-1"&gt;&lt;a href="#"&gt;&lt;span&gt;A tab&lt;/span&gt; &lt;/a&gt;&lt;/li&gt;
        &lt;li role="tab" tabindex="-1"&gt;&lt;a href="#"&gt;&lt;span&gt;Another tab&lt;/span&gt; &lt;/a&gt;&lt;/li&gt;
        &lt;li role="tab" class="selected" tabindex="0"&gt;&lt;a href="#"&gt;&lt;span&gt;Current tab&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
        &lt;li role="tab" tabindex="-1"&gt;&lt;a href="#"&gt;&lt;span&gt;The last tab&lt;/span&gt; &lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;</pre>

<h3>Background images</h3>
<p>Two background images are used. One for the tabs and another for the tab panel. </p>
<p>The tabs background image has three sprites, the upper one is used to display the tab in its normal state, the middle one to show the rollover effect and the bottom one is for the selected tab.</p>
<div>
<img title="Tab's background image" alt="button" src="http://gabriel.prat.name/css.back/tabs.gif" />
</div>
<p>The tab panel background image is just a rounded corners square as big as the maximum desired size of the panel (1000x1000 pixels on our example). Not fully displayed in the image below.</p>
<div style="overflow: hidden; width: 400px; height: 100px;">
<img title="Tab panel's background image" alt="button" src="http://gabriel.prat.name/css.back/round-box.gif" />
</div>

<h3><abbr title="Accessible Rich Internet Applications">WAI-ARIA</abbr> roles and attributes</h3>
<p>The main content of the page is placed inside the tab panel, so the tab panel has the <code>main</code> role. From the specification [<a shape="rect" href="#def-ARIA">ARIA</a>] in the <code>main</code> role definition:</p>
<blockquote>
<p>This marks the content that is directly related to or expands upon the central topic of the document. The <code>main</code> <a href="http://www.w3.org/TR/2009/WD-wai-aria-20090224/#def_Role" class="termref" shape="rect">role</a> is a non-obtrusive alternative for "skip to main content" links, where the navigation option to go to the main content (or other landmarks) is provided by the <a href="http://www.w3.org/TR/2009/WD-wai-aria-20090224/#def_useragent" class="termref" shape="rect">user agent</a> through a dialog or by an <a href="http://www.w3.org/TR/2009/WD-wai-aria-20090224/#def_at" class="termref" shape="rect">assistive technology</a>.</p>
</blockquote>
<p>It is also given the <code>tabpanel</code> role following the <a href="http://www.w3.org/TR/2009/WD-wai-aria-practices-20090224/#tabpanel">tabpanel design pattern</a> in the <abbr title="Accessible Rich Internet Applications">WAI-ARIA</abbr> best practices  [<a shape="rect" href="#def-ARIA-PRACTICES">ARIA-PRACTICES</a>].</p>
<p>The <code>ul</code> are given the <code>tablist</code> and <code>tab</code> roles following the same design pattern linked above. In this way the user-agent or the assistive technologies can identify the list and the panel to be part of a single tab panel widget and help the user interact with it.</p>
<p>Finally, as in our example the tab panel is not a simple panel in a page but it is also the main navigation of the site, the role <code>navigation</code> is also given to the tab list.</p>
<p>Some other <abbr title="Accessible Rich Internet Applications">WAI-ARIA</abbr> attributes are used following the tabpanel design pattern linked above.

</p><h3><abbr title="Cascading Style Sheets">CSS</abbr></h3>
<p>The first part of the <abbr title="Cascading Style Sheets">CSS</abbr> controls the global position of the tabs and tab panel inside the content <code>div</code>. It basically positions the tabs at the top of the content div and the tab panel just below them.</p>
<pre>#content {
	position: relative;
	width: 80%;
	margin: auto;
}

#content .tablist {
	position: absolute;
	top: 0;
	left: 50px;
	width: 100%;
}

#content .tabpanel {
	position: relative;
	top: 44px;
	left: 0;
	margin-bottom: 50px;
}</pre>

<p>The next section sets the <code>inline</code> display of the tabs and adjusts font sizes and line heights to make the images align properly. It also sets the background images for the different states of the tabs</p>
<pre>ul.tablist {
	display: inline;
	font-size: 38px;
	height: 44px;
	line-height: 44px;
	list-style-image: none;
	list-style-type: none;
	overflow: hidden;
	padding: 0;
	margin: 0;
}

ul.tablist li {
	background: #e4e4e4 url(tabs.gif) no-repeat left top;
	display: inline;
	margin: 0 0.1em 0 0;
	padding: 0 0 0 0.5em;
}

ul.tablist li a span {
	font-family: "Lucida Grande", Lucida, Verdana, sans-serif;
	font-size: 16px;
	vertical-align: middle;
	line-height: 51px;
}

ul.tablist li a {
	background: url(tabs.gif) no-repeat right top;
	color: #888;
	display: inline;
	padding: 0 0.5em 0 0;
	text-decoration: none;
}

ul.tablist li.selected {
	background-position: left -88px;
}

ul.tablist li.selected a {
	background-position: right -88px;
	color: #000;
}

ul.tablist li:hover {
	background-position: left -44px;
}

ul.tablist li:hover a {
	background-position: right -44px;
}

ul.tablist li.selected:hover {
	background-position: left -88px;
}

ul.tablist li.selected:hover a {
	cursor: default;
	background-position: right -88px;
}

ul.tablist li.selected {
	cursor: default;
}</pre>
<p>Finally the last section controls the display of the tab panel, setting the background image to its different elements to produce the effect of the rounded corners.</p>
<pre>.tabpanel {
	background: #e4e4e4;
	margin: auto;
}

.tabpanel h2 {
	margin: 0 0 1em 0;
	color: #2e2e2e;
	font-size: 2em;
	font-style: normal;
	font-weight: bold;
}

.tabpanel  ,.tabpanel .bd,.tabpanel .hd,.tabpanel .hd h2 {
	background: transparent url(round-box.gif) no-repeat bottom right
}

.tabpanel {
	padding-right: 15px;
	margin: auto;
	max-width: 1000px;
	max-height: 1000px;
}

.tabpanel .hd {
	background-position: top right;
	margin-right: -15px;
	padding-right: 40px
}

.tabpanel .hd h2 {
	background-position: top left;
	margin: 0;
	border: 0;
	padding: 25px 0 15px 40px;
}

.tabpanel .bd {
	background-position: bottom left;
	margin-right: 25px;
	padding: 15px 0 15px 40px;
}</pre>

<h3>Example</h3>
In the following page you can see an <a href="http://gabriel.prat.name/css.back/tabs.html">accessible tabbed navigation example</a>.
<h3>References</h3>
<dl>
<dt id="def-ARIA">[ARIA]</dt>
<dd><cite><a shape="rect" href="http://www.w3.org/TR/2009/WD-wai-aria-20090224">Accessible Rich Internet Applications (WAI-ARIA) Version 1.0</a></cite>. L. Seeman, M. Cooper, R. Schwerdtfeger, L. Pappas, Editors, W3C Working Draft (work in progress), 24 February 2009. This version of <acronym title="Web Accessibility Initiative">WAI</acronym>-<acronym title="Accessible Rich Internet Applications">ARIA</acronym> is available at http://www.w3.org/TR/2009/WD-wai-aria-20090224/. <a shape="rect" href="http://www.w3.org/TR/wai-aria/">Latest version of <acronym title="Web Accessibility Initiative">WAI</acronym>-<acronym title="Accessible Rich Internet Applications">ARIA</acronym></a> available at http://www.w3.org/TR/wai-aria/.</dd>
<dt id="def-ARIA-PRACTICES"><a id="ref_ARIA-PRACTICES" name="ref_ARIA-PRACTICES" shape="rect"></a>[ARIA-PRACTICES]</dt><dd><cite><a href="http://www.w3.org/TR/2009/WD-wai-aria-practices-20090224/" shape="rect">WAI-ARIA Best Practices</a></cite>. L. Pappas, R. Schwerdtfeger, M. Cooper, Editors, W3C Working Draft (work in progress), 24 February 2009. This version of WAI-ARIA Best Practices is available at http://www.w3.org/TR/2009/WD-wai-aria-practices-20090224/. <a href="http://www.w3.org/TR/wai-aria-practices/" shape="rect">Latest version of WAI-ARIA Best Practices</a> available at http://www.w3.org/TR/wai-aria-practices/. </dd>
<dt id="def-CSS"><a id="ref_CSS" name="ref_CSS" shape="rect"></a>[CSS]</dt><dd><cite><a href="http://www.w3.org/TR/1998/REC-CSS2-19980512/" shape="rect">Cascading Style Sheets, level 2 (CSS2) Specification</a></cite>, I. Jacobs, B. Bos, H. Lie, C. Lilley, Editors, W3C Recommendation, 12 May 1998, http://www.w3.org/TR/1998/REC-CSS2-19980512/. <a href="http://www.w3.org/TR/CSS2/" title="Latest version of Cascading Style Sheets, level 2 (CSS2) Specification" shape="rect">Latest version of CSS2</a> available at http://www.w3.org/TR/CSS2/.</dd>
<dt id="def-XHTMLMOD"><a id="ref_XHTMLMOD" name="ref_XHTMLMOD" shape="rect"></a>[XHTMLMOD]</dt><dd>

            <cite>
               <a href="http://www.w3.org/TR/2008/REC-xhtml-modularization-20081008/" shape="rect">XHTML™ Modularization 1.1</a>
            </cite>, S. Peruvemba, S. McCarron, D. Austin, M. Ishikawa, M. Birbeck,  Editors, W3C Recommendation, 8 October 2008, http://www.w3.org/TR/2008/REC-xhtml-modularization-20081008/. <a href="http://www.w3.org/TR/xhtml-modularization/" title="Latest version of XHTML™ Modularization 1.1" shape="rect">Latest version</a> available at http://www.w3.org/TR/xhtml-modularization/.</dd>
</dl>]]>
        
    </content>
</entry>

<entry>
    <title>Cross-browser inline rounded-corners input buttons and links</title>
    <link rel="alternate" type="text/html" href="http://gabriel.prat.name/css/2009/10/cross-browser-inline-rounded-corners-input-buttons-and-links.html" />
    <id>tag:gabriel.prat.name,2009:/css//1.2</id>

    <published>2009-10-12T18:04:31Z</published>
    <updated>2011-09-26T21:18:34Z</updated>

    <summary>Why are they better than other rounded corners input buttons and links? Their size change to fit the button text They keep the elements&apos; inline display so it can be used in a line of text As thay are not...</summary>
    <author>
        <name>Gabri</name>
        
    </author>
    
        <category term="widgets" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en-US" xml:base="http://gabriel.prat.name/css/">
        <![CDATA[<h3>Why are they better than other rounded corners input buttons and links?</h3>

<ul>
<li>Their size change to fit the button text</li>
<li>They keep the elements' inline display so it can be used in a line of text</li>
<li>As thay are not a block elements, no <code>float</code> is needed so they can be centered or used inside a floated container</li>
<li>They have a pure css rollover and pushed effects (except in IE6)</li>
<li>They use only one image to improve download speed and avoid delays showing the rollover or pushed effects</li>
<li>They have simple semantic valid XHTML strict markup and valid CSS 2.1 without any hacks or tricks</li>
<li>Tested with IE5, IE5.5, IE6, IE7, IE8, FF1, FF2, FF3, Opera
9, Opera 10, Konkeror 4.2, Epiphany 2.2, Safari 3, Safari 4, Chrome 3 and Chrome
4. Available versions for Windows and Ubuntu linux.</li>

</ul>

<h3>Doctype</h3>
This example requires an xhtml-transitional doctype to work, but it can be easily adapted to xhtml strict by adding <code>position: relative;</code> and <code>top: -3px;</code> to the <code>.button span span</code> code to correct the vertical alignment of the text. The number of pixels in the <code>top</code> may vary according to the button and font sizes.

<h3>Markup</h3>

<p>The markup of the link consists of an <code>a</code> tag around two span tags. The
button's text is written into the inner span. Note that all tags are inline
tags so the button can be used both in a line of text or in a block
container. The use of the three tags is needed to support the sliding
door technique and make the code work in FF2 that does not implement the
<code>inline-block</code> display type. The <code>a</code> tag displays the right 
corner of the image and the outer span displays the left one. The elements have the
same background image but they display different parts of it to create
the effect of the sliding door. The background image has to be wide
enough to fit the desired button's text. In this example the button can
be at most 400px wide, but wider buttons can be displayed by creating a
bigger image. <br /></p><p></p><p>A <code>button</code> class has been applied to the <code>a</code> tag to give it the button look and feel. Styles for the span tags are assigned with descendant selectors.</p>

<pre>&lt;a href="#" class="button"&gt;&lt;span&gt;&lt;span&gt;button text&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;</pre>

<p>The markup of the <code>input</code> version follows the same principles and consists of two <code>span</code> tags surrounding the input button.</p>

<pre>&lt;span class="button"&gt;&lt;span&gt;&lt;input type="submit" value="button text" /&gt;&lt;/span&gt;&lt;/span&gt;</pre>

<h3>Background image</h3>
<p>The background image has three buttons, the upper one is used to
display the button in its normal state and the middle one to show the
rollover effect and the bottom one is for the pushed button effect. The white space between them is necessary to avoid a bug in the vertical alignment in IE6 display unwanted parts of the image.</p>
<p><img src="http://gabriel.prat.name/css/bg-btn-corp2.gif" alt="button" title="Button's background image" /></p>


<h3>CSS</h3>
<pre>.button {
	cursor:pointer;
	text-decoration:none;
	background:url(bg-btn-corp2.gif) no-repeat right top; 
	padding-right:10px; 
	display:inline-block;
	line-height:29px;
	height:29px;
	font-size:24px;
	color:#FFFFFF;
	font-weight:bold;
}

span.button {
	vertical-align: middle;
}

.button span { 
	background:url(bg-btn-corp2.gif) no-repeat left top; 
	padding-left:10px;
	line-height:29px;
	height:29px;
	display:inline-block;
}

.button span span {
	background:transparent;
	padding:0;
	
	font-size:14px;
}

.button span input {
	cursor:pointer;
	font-family: inherit;
	font-weight:bold;
	background:transparent;
	border:0;
	padding-top:5px;
	font-size:14px;
	color:#FFFFFF;
}


.button:hover {
	background-position:right -39px;
}

.button:hover span {
	background-position:left -39px;
}

.button:active {
  background-position:right -78px;
}

.button:active span {
  background-position:left -78px;
}
</pre>

<h3>Examples</h3>
<h4>In a line of text</h4>
<p>

These <span class="button"><span><input value="buttons" type="submit" /></span></span> and <a href="#" class="button"><span><span>links</span></span></a> are used as inline
<span class="button"><span><input value="elements" type="submit" /></span></span> in a line of <a href="#" class="button"><span><span>text</span></span></a>.
</p>
<hr>
<h4>Within lists</h4>
<ol>
	<li><span class="button"><span><input value="button1" type="submit" /></span></span></li>
	<li><a href="#" class="button"><span><span>link1</span></span></a></li>
	<li><span class="button"><span><input value="button2" type="submit" /></span></span></li>
</ol>
<hr>
<h4>In floated containers</h4>
<div style="float: left; width: 20%;">This example shows the use of button-like links inside floated containers.</div>
<div style="float: left; width: 20%;"> This div is left floated and contains a <span class="button"><span><input value="button" type="submit" /></span></span> and a <a href="#" class="button"><span><span>link</span></span></a></div>
<div style="float: right; width: 36%;"> This div is right floated and contains <span class="button"><span><input value="another button" type="submit" /></span></span> and <a href="#" class="button"><span><span>another link</span></span></a></div>

<hr>
<h4>Centered</h4>
<div style="margin: auto; text-align: center;"><span class="button"><span><input value="Centered button" type="submit" /></span></span></div>
<div style="margin: auto; text-align: center;"><a href="#" class="button"><span><span>Centered link</span></span></a></div>
<hr>]]>
        
    </content>
</entry>

</feed>

