<?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>David Anderson&#039;s Unfinished Symphony &#187; Web Development</title>
	<atom:link href="http://www.ap4a.co.uk/archives/category/web-dev/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ap4a.co.uk</link>
	<description>It&#039;s about the internet and stuff.</description>
	<lastBuildDate>Sat, 27 Feb 2010 12:31:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Tables in the CSS Age</title>
		<link>http://www.ap4a.co.uk/archives/2008/tables-in-the-css-age/</link>
		<comments>http://www.ap4a.co.uk/archives/2008/tables-in-the-css-age/#comments</comments>
		<pubDate>Sun, 21 Sep 2008 13:46:15 +0000</pubDate>
		<dc:creator>David Anderson</dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.ap4a.co.uk/?p=87</guid>
		<description><![CDATA[As CSS began to gain popularity the use of tables for layouts, quite rightly, began to lessen. However one of the side effects of this was that less developers were learning how to use and markup a table, for any purpose. Subsequently we&#039;d often see examples of developers using nested &#60;div&#62;s, painstakingly positioned with CSS, [...]]]></description>
			<content:encoded><![CDATA[<p>As CSS began to gain popularity the use of tables for layouts, quite rightly, began to lessen. However one of the side effects of this was that less developers were learning how to use and markup a table, for any purpose. Subsequently we&#039;d often see examples of developers using nested &lt;div&gt;s, painstakingly positioned with CSS, being used to layout data tables which as a result fails to provide any semantic information about what is being presented. Or in some cases actual table markup used with no idea or consideration about the semantics of the elements used, which is something that I saw again only today. Given the prevalence of those scenarios I think a simple guide to laying out a data table might be helpful to some.</p>
<p>Before starting with the code to use we need to consider the components of a data table and why they&#039;re used:</p>
<ol>
<li>
<h3>Table Summary</h3>
<p>This component is one that is more frequently overlooked, as it&#039;s the one we can&#039;t see in use and the one that has no equivalent in print, however it is an important component. A table summary is added by way of a summary attribute on the opening table tag and provides a summary that can be read out by screen readers to allow visually impaired users to get a better grasp of the content and context of the table.</p>
</li>
<li>
<h3>Caption</h3>
<p>The caption sits outside of the main table when viewed in the browser and provides a contextual heading for what follows.</p>
</li>
<li>
<h3>Column Groups and Columns</h3>
<p>Data tables often have structurally related columns which can be defined within colgroup elements. The colgroup element can be used to define the width of the columns in the group and also, via the span attribute, the number of adjacent columns that is being defined within the group. If all columns in the table are structurally related then you can use the span to state this. If none are related you would just omit the colgroup element from your markup. The col element is used to define the properties of non-structurally related groups of columns (when used outside of the colgroup element), or to define changes in the properties of a subset of columns within a colgroup.</p>
</li>
<li>
<h3>The Table Header</h3>
<p>The table header can contain the headings for simple tables where the top row(s) of cells contain the column headings for the cells that follow. For more complex tables, the table header can still be used to define headings for the entire table, but as you can only have one table header section you can&#039;t define separate ones for subsection headings. The table header must contain at least one row, and the row must contain at least one cell, however the table header is optional rather than compulsory.</p>
</li>
<li>
<h3>The Table Footer</h3>
<p>The table footer can contain the footer data for simple tables, such as footnotes used to define or describe essential information. As with the table header, you can only have one footer section and so you can&#039;t define separate footers for subsections, only a single overall footer for the entire table. As with the table header, the footer is optional but if used it must contain at least one row, with the row containing at least one cell.</p>
</li>
<li>
<h3>The Table Body</h3>
<p>The title for this section shouldn&#039;t really read &#034;the&#034; table body as, unlike the table header and table footer, there can be more than one table body. This is useful for separating sections of a complex table into distinct groups of data rows. Each table body that is defined must, as with the table header and table footer, contain at least one row with at least one cell inside it. The table header, table footer and all table bodies must contain the same number of columns, however columns can be merged by using the colspan attribute should you need a different number of cells in a given row.</p>
</li>
<li>
<h3>Table Rows</h3>
<p>Table rows are used as structural containers for rows of data cells.</p>
</li>
<li>
<h3>Table Cells</h3>
<p>These are defined by &lt;th&gt; and &lt;td&gt; tags, where they create heading cells and data cells respectively. Headings are used to contain heading data that defines or describes the data that follows, while the data cells contain that data.</p>
</li>
</ol>
<p>Now that we know and understand the components of a data table we can begin to structure one in a meaningful and accessible way:</p>
<dl class="code">
<dt>The opening code for a simple data table:</dt>
<dd>
<ol>
<li><code>&lt;table summary="An example of a simple data table containing dummy data"&gt;</code></li>
<li><code>&lt;caption&gt;A dummy data table&lt;/caption&gt;</code></li>
<li><code>&lt;colgroup span="4" width="100"&gt;&lt;/colgroup&gt;</code></li>
</ol>
</dd>
</dl>
<p>The code above demonstrates an example of the opening code for a table and includes the sections that define the table, including aspects of its structure, but none of the data containing aspects. Line 1 contains the opening table tag and the summary attribute which has an explanation of what the table and its data is about. Line 2 contains the caption which, in this example, is a shortened version of the summary which succinctly describes what is to follow. Line 3 contains a single colgroup element which defines the width (of the 4 columns that are a part of that group.</p>
<p>If you wanted to set a column to have a different width you could do so simply by including a couple of col elements nested within the opening and closing tags:</p>
<ol class="code">
<li><code>&lt;colgroup width="100"&gt;</code></li>
<li><code>&lt;col span="3" /&gt;</code></li>
<li><code>&lt;col span="1" width="250" /&gt;</code></li>
<li><code>&lt;/colgroup&gt;</code></li>
</ol>
<p>On line 1 of the above code we have the opening colgroup tag again, however now it only contains a width attribute that defines the width of the columns in the group. Line 2 then defines the number of columns within the group that have that width setting, and line 3 defines a 4th member of the group that has a different width to the others, with line 4 closing the colgroup. Also permissable is to just use the colgroup elements as containers for col elements which are then used to define the numbers of rows, and their widths, within the colgroup, for simplicity this is the method that I most often use. For example:</p>
<ol class="code">
<li><code>&lt;colgroup&gt;</code></li>
<li><code>&lt;col span="3" width="100" /&gt;</code></li>
<li><code>&lt;col span="1" width="250" /&gt;</code></li>
<li><code>&lt;/colgroup&gt;</code></li>
</ol>
<p>Now that we&#039;ve opened our table and defined a number of its properties we can begin to create the data containing sections:</p>
<dl class="code">
<dt>The table header &amp; table footer sections for a simple data table:</dt>
<dd>
<ol>
<li><code>&lt;thead&gt;</code></li>
<li class="cl2"><code>&lt;tr&gt;</code></li>
<li class="cl3"><code>&lt;th scope="col"&gt;Name&lt;sup&gt;1&lt;/sup&gt;&lt;/th&gt;</code></li>
<li class="cl3"><code>&lt;th scope="col"&gt;Age&lt;/th&gt;</code></li>
<li class="cl3"><code>&lt;th scope="col"&gt;Place of Birth&lt;/th&gt;</code></li>
<li class="cl3"><code>&lt;th scope="col"&gt;Height&lt;/th&gt;</code></li>
<li class="cl2"><code>&lt;/tr&gt;</code></li>
<li><code>&lt;/thead&gt;</code></li>
<li><code>&lt;tfoot&gt;</code></li>
<li class="cl2"><code>&lt;tr&gt;</code></li>
<li class="cl3"><code>&lt;td colspan="4"&gt;&lt;sup&gt;1&lt;/sup&gt; Pretend names for pretend people&lt;/td&gt;</code></li>
<li class="cl2"><code>&lt;/tr&gt;</code></li>
<li><code>&lt;/tfoot&gt;</code></li>
</ol>
</dd>
</dl>
<p>The above block of code contains the table header (&lt;thead&gt; on line 1, ending on line 8 with the &lt;/thead&gt;) and table footer (&lt;tfoot&gt; on line 9, ending on line 13 with the &lt;/tfoot&gt;) sections. Lines 2 &amp; 10 and 7 &amp; 12 define the opening and closing table row tags respectively, with lines 3-6 containing heading cells and line 11 a single data cell in the footer. Each of the heading cells contains a scope attribute, this can be set to either col or row depending on which direction it needs to be read in, here the value of col is set to define the data cells in the column below as belonging to it. I&#039;ll discuss using scope=&#034;row&#034; in the section on the tbody later on.</p>
<p>For more complex tables the id and headers attributes can be used to define heading relationships between th and td cells. For information on that check the W3C section on the <a href="http://www.w3.org/TR/html4/struct/tables.html#adef-headers" class="external">headers attribute</a>, and also the <a href="http://www.w3.org/TR/html4/struct/tables.html#adef-axis" class="external">axis attribute</a>. Also, if our headings had needed to be longer and/or more complex we could have used abbreviations in conjunction with the <a href="http://www.w3.org/TR/html4/struct/tables.html#adef-abbr" class="external">abbr attribute</a>.</p>
<p>In the table footer a single cell has been created by merging all the columns into one using the colspan attribute with a value of 1. Here a footnote, denoted by the use of a superscript #1 has been used to describe an aspect of the data in one of the heading cells.</p>
<p>Finally we come to the tbody (of which there may be more than one) where the data is presented:</p>
<dl class="code">
<dt>The table body section</dt>
<dd>
<ol>
<li><code>&lt;tbody&gt;</code></li>
<li class="cl2"><code>&lt;tr&gt;</code></li>
<li class="cl3"><code>&lt;th scope="row"&gt;Joe Blogs&lt;/th&gt;</code></li>
<li class="cl3"><code>&lt;td&gt;32&lt;/td&gt;</code></li>
<li class="cl3"><code>&lt;td&gt;Liverpool&lt;/td&gt;</code></li>
<li class="cl3"><code>&lt;td&gt;6' 1"&lt;/td&gt;</code></li>
<li class="cl2"><code>&lt;/tr&gt;</code></li>
<li><code>&lt;/tbody&gt;</code></li>
<li><code>&lt;/table&gt;</code></li>
</ol>
</dd>
</dl>
<p>On line 1, above, we open the first tbody section (and the only one for this example table). On line 2 we define the opening of the first table row, closing it on line 7, while on lines 3-6 we define the data cells within that row. On line 3 we have our opening data cell, which falls under the heading of Name (see the header section above) and contains the name of our example person. I&#039;ve also set that data cell to be a heading cell by marking it up with &lt;th&gt; instead of &lt;td&gt;, and as this is a heading that sets a relationship with the other cells in its row it has a scope attribute with the value of row to establish this. Lines 4, 5 and 6 are simple data cells containing data that is headed by the main column headings defined in the header section earlier, but also by the row heading defined here. Finally, on line 8 we close the table body and on line 9 we close the entire table. If we put all of the component parts together we&#039;ll have the full markup for a simple data table:</p>
<dl class="code">
<dt>The full markup for a simple data table:</dt>
<dd>
<ol>
<li><code>&lt;table summary="An example of a simple data table containing dummy data"&gt;</code></li>
<li><code>&lt;caption&gt;A dummy data table&lt;/caption&gt;</code></li>
<li><code>&lt;colgroup span="4" width="100"&gt;&lt;/colgroup&gt;</code></li>
<li><code>&lt;thead&gt;</code></li>
<li class="cl2"><code>&lt;tr&gt;</code></li>
<li class="cl3"><code>&lt;th scope="col"&gt;Name&lt;sup&gt;1&lt;/sup&gt;&lt;/th&gt;</code></li>
<li class="cl3"><code>&lt;th scope="col"&gt;Age&lt;/th&gt;</code></li>
<li class="cl3"><code>&lt;th scope="col"&gt;Place of Birth&lt;/th&gt;</code></li>
<li class="cl3"><code>&lt;th scope="col"&gt;Height&lt;/th&gt;</code></li>
<li class="cl2"><code>&lt;/tr&gt;</code></li>
<li><code>&lt;/thead&gt;</code></li>
<li><code>&lt;tfoot&gt;</code></li>
<li class="cl2"><code>&lt;tr&gt;</code></li>
<li class="cl3"><code>&lt;td colspan="4"&gt;&lt;sup&gt;1&lt;/sup&gt; Pretend names for pretend people&lt;/td&gt;</code></li>
<li class="cl2"><code>&lt;/tr&gt;</code></li>
<li><code>&lt;/tfoot&gt;</code></li>
<li><code>&lt;tbody&gt;</code></li>
<li class="cl2"><code>&lt;tr&gt;</code></li>
<li class="cl3"><code>&lt;th scope="row"&gt;Joe Blogs&lt;/th&gt;</code></li>
<li class="cl3"><code>&lt;td&gt;32&lt;/td&gt;</code></li>
<li class="cl3"><code>&lt;td&gt;Liverpool&lt;/td&gt;</code></li>
<li class="cl3"><code>&lt;td&gt;6' 1"&lt;/td&gt;</code></li>
<li class="cl2"><code>&lt;/tr&gt;</code></li>
<li><code>&lt;/tbody&gt;</code></li>
<li><code>&lt;/table&gt;</code></li>
</ol>
</dd>
</dl>
<p>This will then be presented in the browser like this:</p>
<table summary="An example of a simple data table containing dummy data">
<caption>A dummy data table</caption>
<colgroup span="4" width="100"></colgroup>
<thead>
<tr>
<th scope="col">Name<sup>1</sup></th>
<th scope="col">Age</th>
<th scope="col">Place of Birth</th>
<th scope="col">Height</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="4"><sup>1</sup> Pretend names for pretend people</td>
</tr>
</tfoot>
<tbody>
<tr>
<th scope="row">Joe Blogs</th>
<td>32</td>
<td>Liverpool</td>
<td>6&#039; 1&#034;</td>
</tr>
</tbody>
</table>
<p><strong>Note:</strong> that table is using the table styling set in my CSS. If you were to use that example elsewhere you would need to create your own CSS to style it otherwise it would use the browser default styling. If anyone needs tips on how to do that then let me know and I can create a follow up tutorial for that. Similarly, if there&#039;s anything that needs clarification please leave a comment and ask, I&#039;ll be happy to help.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ap4a.co.uk/archives/2008/tables-in-the-css-age/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Redesign</title>
		<link>http://www.ap4a.co.uk/archives/2007/redesign/</link>
		<comments>http://www.ap4a.co.uk/archives/2007/redesign/#comments</comments>
		<pubDate>Tue, 22 May 2007 00:44:37 +0000</pubDate>
		<dc:creator>David Anderson</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.ap4a.co.uk/archives/2007/redesign/</guid>
		<description><![CDATA[Regular visitors to the site should notice quite a radical change of design here which I&#039;m hoping will make it a bit more visually pleasing. When I first started the site it was, almost literally, just thrown together in a hurry and without a finalised design. This was basically because there were a number of [...]]]></description>
			<content:encoded><![CDATA[<p>Regular visitors to the site should notice quite a radical change of design here which I&#039;m hoping will make it a bit more visually pleasing. When I first started the site it was, almost literally, just thrown together in a hurry and without a finalised design. This was basically because there were a number of people that wanted the blog up and running and, I think, for me to start posting on it. Some of you may still remember the original look of the site, which was far from complete and so a little bit broken to say the least. After a little <a href="http://www.kevinleitch.co.uk/wp/?p=301" class="external">feedback</a>  I decided not to continue working with that design and came up with a working temporary one instead. Even though it provided everything I wanted from it (functionality, flexibility and simplicity) it was a little uninspiring and I was never really happy with it, despite that it managed to survive for a couple of years.</p>
<h3>Simplifying the Interface</h3>
<p>What I&#039;ve tried to do with the new design is keep the important concepts intact &#8211; it&#039;s still, I believe, functional; it&#039;s still flexible, though now within a set limit; and, importantly, it&#039;s still simple. In fact I&#039;ve made an effort to simplify it further. I found certain aspects of the old design were slightly cluttered, notably the links sidebar. In order to de-clutter the link heavy sidebar I separated the archives and external links section into their own pages, with them linked via a new primary menu. I&#039;ve also used a little <abbr title="PHP Hypertext Preprocessor">PHP</abbr> and hidden the <a href="http://www.mybloglog.com" class="external">MyBlogLog</a> widget from everyone but myself.</p>
<p>All in all I think the sidebar is cleaner and more useful while still sharing things that I want to share. Also, perhaps the most noticeable change is the dropping of the third column from the front page. My original idea for that was to allow the front page of the site to show the latest post in full whilst also showing the next 5 or 6 most recent posts, but rather than overloading the page with too much content these recent posts would just have excerpts showing on the front. The old design did achieve that fairly well, however the extra column meant that the front page would always seem a little cramped. It&#039;s also not necessary to have a third column in order to provide direct access to that content from the front page, so it got dropped.</p>
<h3>New Sections</h3>
<p>I&#039;ve added a few extra sections to the site where I can provide supplementary information, such as an accessibility statement and privacy policy, including an about page. At the moment the about page is a bit bare; I do intend to put something in there at some point, hence its inclusion, however I haven&#039;t decided on what exactly I want to say. I&#039;ve also extended the subscription page to include information about my feeds, feed readers and feed aggregators along with the original email subscription option that I&#039;ve carried over from the previous version. There&#039;s also a contact form, just in case.</p>
<h3>Ironing out the Issues</h3>
<p>As with any project, there have been issues to resolve (I&#039;m talking specifically about coding issues at this point).</p>
<h4>PHP Issues</h4>
<p>One of the things I wanted was for the archives page to show each category with all the posts for that category, to be able to reorder the categories, to be able to show the date of each post adjacent to the link to the post and to be able to structure markup how I wanted. One of the great things about <a href="http://www.wordpress.org" class="external">WordPress</a> is its ease of templating, and to that end the <a href="http://codex.wordpress.org" class="external">codex</a> provides details of the variety of template tags available for this, however those available for templating category listings didn&#039;t quite meet all of my requirements. This is where <a href="http://www.stuffbysarah.net" title="Sarah's blog" rel="external" class="external">Sarah</a> came in with a bit of help, well a lot of help, providing me with the PHP needed to pull the required information from the database in the way that I wanted. She also helped me write the PHP for my contact form, in the process helping me to add in fields checking for spammers, and also code to check that those fields had been completed appropriately.</p>
<p>The site used to use an old version of the <a href="http://subscribe2.wordpress.com/" class="external">Subscribe2</a> plugin which I held off from upgrading to the amount of work it would have taken to get a newer version to work with the existing theme. A new theme has meant that was no longer a consideration, and so I upgraded to the latest version of Subscribe2. It was only when I uploaded, and set live, the completed theme and upgraded plugins at the weekend that a few issues came to light. Basically the plugin only partially worked on the live site, with new subscribers receiving an email containing a link to confirm the subscription, but the link going to a blank page and the subscription not being confirmed. After a lot of reading through the plugin code, and with Sarah doing a number of tests, we found that there were three functions responsible for the confirmation process &#8211; commenting out the call to one of these functions allowed the confirmation to go through and the appropriate confirmation page to display &#8211; just in a very broken state as a number of scripted components failed to work on the page. It had, by that time, occurred to us that it was an issue with using customised permalinks on the site along with the way the plugin takes over an existing page that it rewrites with the confirmation &#8211; instead of doing this successfully the page was being redirected to the real permalinked page, causing the confirmation to fail. Once we had tested that this was the case, by resetting permalinks to the default method, it didn&#039;t take much to discover the real cause &#8211; a conflict between Subscribe2 and the <a href="http://fucoder.com/code/permalink-redirect/" class="external">Permalink Redirect</a> plugin. This issue hadn&#039;t existed with the previous version of Subscribe2 that I&#039;d been using, so something that has changed caused the conflict &#8211; the process of taking over an existing page from the database, rather than using its own dedicated one like the old version did. It&#039;s probable that the new method makes it easier for the plugin to be integrated with a theme and so it&#039;s an acceptable change in the grand scheme of things, but unfortunate that it results in a conflict. To fix it I dropped the other plugin.</p>
<h4>CSS Issues</h4>
<p>While differences in browser rendering continue to exist there are always going to be display issues when switching between those browsers. The star browser was Firefox, getting things right first time and according to standards. Internet Explorer 7 had a few minor issues, and IE 6 a few more, however these were relatively simple to fix with a few changes in margin, width and position settings in their own respective style sheets linked via conditional comments. In Internet Explorer 5.5 it looked like a bomb had hit it; that browser couldn&#039;t handle a fair bit of the CSS and rather than spend too much time on an obsolete browser I changed a number of things and fixed the width. I basically just wanted to make sure the site would be usable rather than trying to precisely reproduce the design.</p>
<p>Quite surprisingly I had a few strange problems in Opera 9.20, surprisingly because Opera is at least as standards compliant as Firefox if not more so. However there were several oddities that didn&#039;t seem to have an easy fix, or at least not a fix that could be achieved simply by tweaking the CSS without those tweaks affecting other browsers. Those issues included:</p>
<ul>
<li>displaying the sponsor links at the correct size until the page finished loading, then the text mysteriously shrinking. As these used the same markup and CSS as the other links in the sidebar there was no easy or logical way to fix the problem without affecting the other links.</li>
<li>text marked up as paragraphs within the content area would magically jump to the right once the page loaded, leaving a small fragment of text behind (a few characters from the last line of each paragraph, chopped off at the top). Again, there was no simple fix without it affecting the positioning in other browsers.</li>
<li>text link styles were overridden with the browser default ones, again without any logic that I could see. It&#039;s possible that one of the settings in my browser profile caused this issue, but I&#039;m not familiar enough with the browser to track it down &#8211; so I needed to find another fix.</li>
</ul>
<p>It&#039;s likely that the first two issues were caused by the combination of scripts used on the page, for example the sponsor links are generated by scripts. However as it wasn&#039;t feasible to remove those scripts anyway I decided not to test the theory by disabling them on a live site (the issues weren&#039;t apparent in my local testing copy). Due to the prospect of a CSS fix affecting other browsers I had to find a hack or filter for Opera, much as it pains me to use them now that it&#039;s clear we can control the real problem browser (Internet Explorer 6 and under) using conditional comments. However these issues needed an Opera specific fix and, after a bit of searching on <a href="http://www.google.co.uk" class="external">Google</a>, I found a way using an @media declaration to target Opera:</p>
<ol class="code">
<li><code>@media all and (min-width:0px) {</code></li>
<li><code>head~body p {</code></li>
<li><code>	margin-left : 0;</code></li>
<li><code>}</code></li>
<li><code>#content a, #content a:link, #content a:visited, #skipper a:link, #skipper a:visited {</code></li>
<li><code>	color : #00303e !important;</code></li>
<li><code>}</code></li>
<li><code>#content a:hover, #content a:active, #content a:focus, #skipper a:hover, #skipper a:active, #skipper a:focus {</code></li>
<li><code>	color : #870000 !important;</code></li>
<li><code>}</code></li>
<li><code>#sidebar #links55315 a {</code></li>
<li><code>	font-size : 11px;</code></li>
<li><code>}</code></li>
<li><code>}</code></li>
</ol>
<p>The combination of the &#034;@media all&#034; and the &#034;and (min-width:0px)&#034; in line 1 of the code above targets Opera fairly specifically &#8211; apparently it has also been shown to target Pre-release versions of Safari too. I had no way of testing this, however I felt it was safe to use the method as I was just emphasising already existing styles rather than trying to impose different ones. Line 2 very specifically targets all paragraphs, overriding any other rules that may be conflicting. Line 3 sets the left margin for all paragraphs to zero (even though this had already been done in the main style sheets), while Line 4 closes the rule set opened in line 2. A quick test in Opera showed that the method worked successfully. Lines 5, 6 and 7, and lines 8, 9 and 10 were used to fix the link colour change, while 11, 12 and 13 were used to fix the resizing of the sponsor link text &#8211; using a pixel unit instead of ems was what was needed there. The final line closes the whole thing. That discovery came courtesy of the <a href="http://tanreisoftware.com/blog/" class="external">Tanrei Software blog</a> where there&#039;s a useful article on using <a href="http://tanreisoftware.com/blog/?p=41" class="external">media selectors for browser targetting</a>.</p>
<h4>Other Issues</h4>
<p>Rather than use a mass of extra markup and images I chose to use Alessandro Fulciniti&#039;s <a href="http://www.html.it/articoli/niftycube/index.html" class="external">NiftyCorners Cube</a> script for the curved corners, so users without javascript enabled will see the site with square corners. Users with javascript may also have some issues, there&#039;s a slight lag in the page load time as the script runs through the targeted elements in order to set the curved corners. It&#039;s also possible that the script contributes to the paragraph jumping in Opera, though I&#039;ve never seen this happen in other sites that I&#039;ve used the script on.</p>
<p>I use a plugin that dynamically adds classes to various links in order to add an icon to identify the target type (such as an arrow pointing away from a box to indicate external links). One of the icons used was for links to <a href="http://en.wikipedia.org/wiki/Main_Page" rel="nofollow" class="external">Wikipedia</a> which consisted of a small icon of the Wikipedia logo. However it was hard to distinguish that icon from the surrounding text, so it was removed.</p>
<p>I wanted to use an image of an upwards pointing arrow for my back to top links, but without all of the images being background images (otherwise there would have been no actual content for the links). I achieved it using a combination of foreground and background images with the following markup and CSS:</p>
<dl class="code">
<dt>The HTML</dt>
<dd>
<ol>
<li><code>&lt;div class="up"&gt;</code></li>
<li><code>&lt;a href="#skipper" title="Back to top"&gt;<br />&lt;img src="http://www.ap4a.co.uk/wp-content/themes/mannequin/images/up.png" width="16" height="16" alt="Up arrow" /&gt;&lt;/a&gt;</code></li>
<li><code>&lt;/div&gt;</code></li>
</ol>
</dd>
</dl>
<p>The markup simply creates a div as a container element for the image used as the default-state up arrow and the actual link back to the top of the page.</p>
<dl class="code">
<dt>The CSS &#8211; part 1</dt>
<dd>
<ol>
<li><code>div.up {</code></li>
<li><code>	float : right;</code></li>
<li><code>	margin : 5px 10px 0 0;</code></li>
<li><code>	padding : 0;</code></li>
<li><code>	width : 16px;</code></li>
<li><code>	height : 16px;</code></li>
<li><code>}</code></li>
</ol>
</dd>
</dl>
<p>The first part of the associated CSS sets the dimensions of the container div to match the size of the image it contains and positions it where I want it on the page (relative to its own container).</p>
<dl class="code">
<dt>The CSS &#8211; part 2</dt>
<dd>
<ol>
<li><code>div.up a, div.up a img {</code></li>
<li><code>	display : block;</code></li>
<li><code>	padding : 0;</code></li>
<li><code>	margin : 0;</code></li>
<li><code>}</code></li>
</ol>
</dd>
</dl>
<p>Part 2 of the CSS sets both the image and the anchor around it to be block level. This corrects Internet Explorer 6&#039;s behaviour of adding a 3px space beneath inline images (which is the space preserved for text descenders). It also allows the full area taken up by the image to be a clickable part of the link.</p>
<dl class="code">
<dt>The CSS &#8211; part 3</dt>
<dd>
<ol>
<li><code>div.up a {</code></li>
<li><code>	background : url(images/up2.png) no-repeat center bottom;</code></li>
<li><code>	position : relative;</code></li>
<li><code>	width : 100%;</code></li>
<li><code>	height : 100%;</code></li>
<li><code>	text-decoration : none;</code></li>
<li><code>	cursor : pointer;</code></li>
<li><code>}</code></li>
</ol>
</dd>
</dl>
<p>This code sets the link to 100% width and height of the container div to complete the process started in the previous rule set, which allows the full area of the image to be clickable. It also sets the positioning to relative to allow the contained image to be absolutely position within it, and the first line sets the background to be the hover state version of the image. The final 2 lines turn off the underline added to links and ensure that the proper cursor style is used.</p>
<dl class="code">
<dt>The CSS &#8211; part 4</dt>
<dd>
<ol>
<li><code>div.up a img {</code></li>
<li><code>	position : absolute;</code></li>
<li><code>	top : -5px;</code></li>
<li><code>	left : -5px;</code></li>
<li><code>	border : none !important;</code></li>
<li><code>}</code></li>
</ol>
</dd>
</dl>
<p>Part four positions the foreground image within its containers so that it precisely and completely covers up the background image. It also makes sure that no border is added.</p>
<dl class="code">
<dt>The CSS &#8211; part 5</dt>
<dd>
<ol>
<li><code>div.up a:hover img, div.up a:active img, div.up a:focus img {</code></li>
<li><code>	visibility : hidden;</code></li>
<li><code>}</code></li>
</ol>
</dd>
</dl>
<p>The final rule set is responsible for removing the foreground image when the link is hovered over, revealing the hover state background image. It works as intended in Firefox, <abbr title="Internet Explorer">IE</abbr> 7 and Opera 9. In IE 5 and 6 the change in state doesn&#039;t work, and IE 5 also needs a slight change in the positioning to cover the hover state image.</p>
<p>No doubt there&#039;ll be other issues to find, and they&#039;ll be fixed when they are. I&#039;m expecting there to be one or two in Mac browsers, but as I haven&#039;t been able to test in them (the Mac testing services I normally use have been broken when I&#039;ve visited recently) I haven&#039;t been able to find them. If you&#039;re a Mac user and do find issues, please let me know and I&#039;ll do my best to resolve them, thanks.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ap4a.co.uk/archives/2007/redesign/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>The First Annual CSS Naked Day</title>
		<link>http://www.ap4a.co.uk/archives/2006/annual-css-naked-day/</link>
		<comments>http://www.ap4a.co.uk/archives/2006/annual-css-naked-day/#comments</comments>
		<pubDate>Tue, 04 Apr 2006 13:15:11 +0000</pubDate>
		<dc:creator>David Anderson</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.ap4a.co.uk/archives/2006/annual-css-naked-day/</guid>
		<description><![CDATA[Dustin Diaz has announced the first annual CSS naked day to take place on the 5th of April. I had wanted to announce my participation in the event prior to my CSS turning off, but I didn&#039;t get the chance to and now it&#039;s gone. Some of you may be wondering why I started early [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.dustindiaz.com/" rel="external" class="external">Dustin Diaz</a> has announced the <a href="http://www.dustindiaz.com/naked-day/" class="external">first annual <abbr title="Cascading style sheets">CSS</abbr> naked day</a> to take place on the 5th of April. I had wanted to announce my participation in the event prior to my CSS turning off, but I didn&#039;t get the chance to and now it&#039;s gone.</p>
<p>Some of you may be wondering why I started early &#8211; well I haven&#039;t really. You see I used the <abbr title="PHP hypertext preprocessor">PHP</abbr> function provided by <a href="http://iluke.net/" rel="external" class="external">Luke Wertz</a> to disable my CSS automatically and, as mentioned by Dustin, this will turn the CSS off as soon as it is the 5th of April anywhere in the World, and keep it turned off until it&#039;s no longer the 5th anywhere. In other words it&#039;s an annual CSS 2 naked days.</p>
<p>To find out what it&#039;s all about have a read of the <a href="http://www.dustindiaz.com/naked-day/" rel="external" title="annual CSS naked day" class="external">announcement</a>, however it&#039;s summed up quite well here by <a href="http://people.opera.com/howcome/" rel="external" class="external">H&aring;kon Wium Lie</a>, the creator of CSS:</p>
<blockquote cite="http://www.dustindiaz.com/naked-day/#comment-2934">
<p>This is a fun idea, fully in line with the reasons for creating CSS in the first place. While most designers are attracted by the extra presentational capabilities, saving <abbr title="HyperText Markup Language">HTML</abbr> from becoming a presentational language was probably a more important motivation for most people who participated in the beginning.</p></blockquote>
<p>H&aring;kon has pledged to take part, along with <a href="http://naked.dustindiaz.com/" rel="external" title="CSS Naked Day home page and participant list" class="external">several hundred other mental people</a> <img src='http://www.ap4a.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>In a little under 48 hours my CSS will return in a blaze of glory, in the meantime you get to see a more attractive ap4a.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ap4a.co.uk/archives/2006/annual-css-naked-day/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Style:Phreak&#039;s Standard Form Layout Revisited</title>
		<link>http://www.ap4a.co.uk/archives/2006/stylephreaks-standard-form-layout-revisited/</link>
		<comments>http://www.ap4a.co.uk/archives/2006/stylephreaks-standard-form-layout-revisited/#comments</comments>
		<pubDate>Thu, 30 Mar 2006 00:07:11 +0000</pubDate>
		<dc:creator>David Anderson</dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.ap4a.co.uk/archives/2006/stylephreaks-standard-form-layout-revisited/</guid>
		<description><![CDATA[In August 2004 Style:Phreak created a demonstration of a standards compliant form marked up with semantic HTML and styled with CSS. I&#039;ve only recently been introduced to it by an acquaintance from a forum I visit occasionally who uses a version based on it and asked how it could be made more semantic following a [...]]]></description>
			<content:encoded><![CDATA[<p>In August 2004 <a href="http://www.stylephreak.com/" rel="external" class="external">Style:Phreak</a> created a demonstration of a standards compliant form marked up with semantic <abbr title="Hypertext Markup Language">HTML</abbr> and styled with <abbr title="Cascading Style Sheets">CSS</abbr>. I&#039;ve only recently been introduced to it by an acquaintance from a forum I visit occasionally who uses a version based on it and asked how it could be made more semantic following a brief discussion about it. As a result of that discussion <a href="http://www.ap4a.co.uk/stuff/formtest/testform1.html" title="Updated Standard Form" class="internal">I&#039;ve taken it upon myself to update it slightly</a>, a possibility brought about due to better support available in current browsers compared to what was available in 2004.</p>
<h4>Variations in this version:</h4>
<ul>
<li>The wrapping of label/input pairs within divs has been dropped as this was only used to allow styling effects to be done to them &#8211; those effects are possible without needing to add the extra markup.</li>
<li>The div surrounding the radio buttons has been replaced with a fieldset, which is more semantic, though it&#039;s responsible for the minor issue in Opera 7.23 outlined below.</li>
<li>Although a tabindex could have been added one hasn&#039;t been &#8211; as this isn&#039;t an active form I decided against this. In a real form one would possibly have been used. Also the erroneous inclusion of one empty tabindex attribute in the original has been omitted here.</li>
<li>The statement, in <a href="http://www.stylephreak.com/uploads/source/cssforms/cssform.php" title="Style:Phreak's Form Demo" rel="external" class="external">the style:phreak original</a>, that fields marked in <strong>bold</strong> are required is reliant on presentation and would mean that screenreader users won&#039;t get the message, this has been replaced with the comment that those marked with a * are required.</li>
<li>As * marked fields are required it is important that all users get to see it, so it&#039;s important that it isn&#039;t included via the <abbr title="Cascading Style Sheets">CSS</abbr> content property, as per the original.</li>
<li>As the contents of the &#034;required fields&#034; paragraph contains essential information relating to the form it&#039;s more meaningful to include it within the form, so that&#039;s done too.</li>
<li>The script used to toggle the optional fields on and off has been removed in this version, however a script to correct a <abbr title="Internet Explorer for Windows">win IE</abbr> bug has been included in order to prevent the resetting of select fields when their label is clicked.</li>
</ul>
<p>This version has been tested and works as intended in the following current Windows browser versions: Internet Explorer 6, Firefox 1.5.0.1 and Opera 8.52. It has also been tested in Opera 7.23 (the lowest version I care about supporting) and found to work with only one error &#8211; where the fieldset surrounding the radio buttons is surrounded by  a border despite the CSS rule setting it to none. In IE 5.02 and IE 5.5 for Windows it works as intended apart from a misplacement of the textarea and its label, and the wrapping of the label for the input above it on to two lines &#8211; I could have corrected this with an IE 5 only stylesheet or a hack, I didn&#039;t care enough to try to.</p>
<p>This version, as with <a href="http://www.stylephreak.com/" rel="external" class="external">Style:Phreak&#039;s</a> original is released under a <a href="http://creativecommons.org/licenses/by-nc-sa/2.0/uk/" title="This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.0 England &amp; Wales License." rel="external" class="external">creative commons licence</a>.</p>
<p><a href="http://www.ap4a.co.uk/stuff/formtest/testform1.html" class="internal">View the updated form here.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ap4a.co.uk/archives/2006/stylephreaks-standard-form-layout-revisited/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>longdesc, it&#039;s not just alternate text</title>
		<link>http://www.ap4a.co.uk/archives/2006/longdesc-its-not-just-alternate-text/</link>
		<comments>http://www.ap4a.co.uk/archives/2006/longdesc-its-not-just-alternate-text/#comments</comments>
		<pubDate>Fri, 17 Feb 2006 14:49:45 +0000</pubDate>
		<dc:creator>David Anderson</dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.ap4a.co.uk/archives/2006/longdesc-its-not-just-alternate-text/</guid>
		<description><![CDATA[Most developers are, I would hope, aware of alt attributes, and hopefully how to use them correctly. It seems, however, that longdesc is a bit of a mystery even to some of the more experienced and knowledgeable amongst us. With an image&#039;s alt attribute we&#039;re able to insert a small segment of text that provides [...]]]></description>
			<content:encoded><![CDATA[<p>Most developers are, I would hope, aware of <abbr title="Alternative">alt</abbr> attributes, and hopefully how to use them correctly. It seems, however, that <abbr title="Long description">longdesc</abbr> is a bit of a mystery even to some of the more experienced and knowledgeable amongst us.</p>
<p>With an image&#039;s alt attribute we&#039;re able to insert a small segment of text that provides an alternative if, for whatever reason, the image is unable to be displayed. It may be something simple, such as &#034;my company logo&#034; to replace your logo when it doesn&#039;t open up. With more complex images, and images that convey very important information such as charts and diagrams, a more detailed description is required &#8211; not in case the image doesn&#039;t display, but to provide an alternative means of providing the detailed information the image contains. In this case the alt  attribute just isn&#039;t enough. It isn&#039;t viable to describe a graph of medical results, for example, in the few words that alt attributes allow us. For circumstances such as in our medical chart example we have been provided a more powerful method with the longdesc attribute. However, due to the mysterious nature of longdesc it seems that many of us are incorrectly using it in the same way as we use alt attributes. To illustrate the point, consider the markup for an embedded image with alt attribute:</p>
<ol class="code">
<li><code>&lt;img src="image.gif" alt="my company logo" /&gt;</code></li>
</ol>
<p>As the above example shows, alt attributes contain our alternative text enclosed between quotation marks and within our image tag.  Longdesc attributes, however, don&#039;t enclose the long description within the confines of its quotation marks, instead longdesc contains a link to another web page where we would describe in detail the image in question. Nor would our longdesc attribute be used to replace our alt attribute &#8211; instead we would use both; for example:</p>
<ol class="code">
<li><code>&lt;img src="compleximage.gif" alt="Results graph of medical data" longdesc="/clinicalresults.html" /&gt;</code></li>
</ol>
<p>Rather than being a more detailed, and direct, replacement for alt attributes the longdesc attribute, and associated descriptive web page, is intended to be used in conjunction with alts in order to enable us to provide our visitors with as much information as they might require about the imagery used.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ap4a.co.uk/archives/2006/longdesc-its-not-just-alternate-text/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>More accessible &#039;more&#039; links</title>
		<link>http://www.ap4a.co.uk/archives/2005/more-accessible-more-links/</link>
		<comments>http://www.ap4a.co.uk/archives/2005/more-accessible-more-links/#comments</comments>
		<pubDate>Sun, 23 Oct 2005 22:14:42 +0000</pubDate>
		<dc:creator>David Anderson</dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.ap4a.co.uk/?p=9</guid>
		<description><![CDATA[Visit most blogs, including those of accessibility minded web designers, and at some point you&#039;ll stumble upon a &#034;more&#034; link. These are links to the full version of excerpted posts which allow bloggers to reduce the volume of text on their home pages. In theory they&#039;re a great idea, in practice though they&#039;re poorly implemented [...]]]></description>
			<content:encoded><![CDATA[<p>Visit most blogs, including those of accessibility minded web designers, and at some point you&#039;ll stumble upon a &#034;more&#034; link. These are links to the full version of excerpted posts which allow bloggers to reduce the volume of text on their home pages. In theory they&#039;re a great idea, in practice though they&#039;re poorly implemented from an accessibility standpoint. The <abbr title="Web Accessibility Initiative">WAI</abbr>&#039;s <a href="http://www.w3.org/TR/WCAG10/" title="The WAI Web Content Accessibility Guidelines" class="external">guidelines</a> state that <q><a href="http://www.w3.org/TR/WCAG10/#gl-facilitate-navigation" title="WCAG guideline 13 - provide clear navigation mechanisms" class="external">link text should be meaningful enough to make sense when read out of context</a></q>, clearly something that &#034;more&#034; fails to do.  Also, as is mentioned in <a href="http://www.w3.org/TR/WCAG10-HTML-TECHS/#link-text" title="WCAG recommended techniques for guideline 13" class="external">the <abbr title="Web Content Accessibility Guidelines">WCAG</abbr> recommended techniques for writing link text</a>, <q>if more than one link on a page shares the same link text, all those links should point to the same resource</q> &#8211; once again, something that &#034;more&#034; generally fails to do.</p>
<p>The problem is, though, that these links and their associated link text are added by the blog software rather than the blogger, and the code running behind the scenes that makes this happen is very often a mystery to the average blogger. Considering the current trend for focusing on accessibility it may be worthwhile for blog software developers to modify this feature. In the case of wordpress, the software used on this site, it was quite easy to adapt the feature to use more appropriate link text than its version of &#034;more&#034; &#8211; thanks to a helping hand from <a href="http://www.stuffbysarah.net" title="Sarah's blog" rel="external" class="external">Sarah</a> who analysed the template functions files and found a way to achieve what I wanted &#8211; which was to have the &#034;more&#034; link include the article&#039;s title in the link text.</p>
<p>If this is something that you&#039;d like to implement on your own wordpress blog you need to <em>edit the template-functions-post.php file located in the wp-includes directory</em>. To do so you need to locate line 86 and replace the existing code found there with the following:</p>
<ol class="code">
<li><code>$output.='&lt;a href="'. get_permalink().</code></li>
<li><code>"#more-$id\">$more_link_text". get_the_title()."&lt;/a&gt;";</code></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.ap4a.co.uk/archives/2005/more-accessible-more-links/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Introduction to the CSS Box Model &#8211; part one</title>
		<link>http://www.ap4a.co.uk/archives/2005/the-css-box-model-part-1-introduction-to-the-box-model/</link>
		<comments>http://www.ap4a.co.uk/archives/2005/the-css-box-model-part-1-introduction-to-the-box-model/#comments</comments>
		<pubDate>Sun, 23 Oct 2005 19:58:37 +0000</pubDate>
		<dc:creator>David Anderson</dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.ap4a.co.uk/?p=8</guid>
		<description><![CDATA[All elements on a web page are contained within rectangular boxes with properties that we&#039;re able to manipulate directly via the use of CSS. This gives us precise control over their dimensions and, therefore, their impact upon their surroundings. We can set the size of the area used to contain the contents, via the width [...]]]></description>
			<content:encoded><![CDATA[<p>All elements on a web page are contained within rectangular boxes with properties that we&#039;re able to manipulate directly via the use of <abbr title="Cascading Style Sheets">CSS</abbr>. This gives us precise control over their dimensions and, therefore, their impact upon their surroundings. We can set the size of the area used to contain the contents, via the width setting, the width of the borders around the box, the amount of space between the contents and the border, and the amount of space between the borders of one box and those of its neighbours. The precision that&#039;s possible to achieve with these settings gives designers a fine degree of control over the layout of the web pages they create.</p>
<p>So what are the settings, and how do we use them? </p>
<p>If we consider that a CSS box is no different to an ordinary cardboard box, with the exact same properties, then it&#039;ll be easier to both visualise and understand the settings we use. The cardboard part of a box is identical in properties to the border that surrounds a CSS box, it&#039;s the part that surrounds and contains the box&#039;s contents. Inside the box is the content area, which in some examples may take up the entire inner area of the box depending on how we pack it. However, sometimes we may want to protect the contents with padding to keep it away from the inner surface of the box. With a cardboard box this may be achieved by padding it with polystyrene, with a CSS box we pad it with empty space. Then, just as with a cardboard box, we may surround it with empty space to keep it away from other boxes &#8211; by using a margin. The combined effects of all four of these properties adds up to create the dimensions of a CSS box:</p>
<p><img src='/wp-content/uploads/boxmod1.gif' alt='Graphical depiction of the CSS box model' width='210' height='150' class="nbord" /></p>
<p>Even the image above is a box that we can manipulate using the CSS box model. It has a width and a height that defines the content area, in this case the size of the image itself. It can be given a border to surround it, and it can have padding between the image and the border, and a margin to surround it all and provide space between it and all of the other objects on this web page. Which brings us to the magic of CSS &#8211; and how we manipulate these properties.</p>
<p>In case you aren&#039;t familiar with CSS I&#039;ll give a very brief rundown of some of the terminology and the syntax involved in creating a CSS style rule. Style rules consist of two principle parts &#8211; 1. an element identifier, the <em>selector</em> and 2. the style <em>declaration</em>. Selectors may be the name of the <abbr title="Hypertext Markup Language">HTML</abbr> element that is the target, or they may be names given by the designer and targeted via either a unique <abbr title="Identifier">ID</abbr> or a class. There are other types of selector, however for the purposes of our exercise we don&#039;t need to know anything more about them now. A declaration contains the style properties that are applied to the element targeted by the selector, and consist of two parts separated by a colon (:) and closed by a semi-colon (;) which is used to separate one style declaration from subsequent ones within the same rule set, and each rule set can contain one or more declarations that we contain within curly braces like these {}.</p>
<p>Now we know a little about how we write CSS we can begin to apply that knowledge to setting the dimensions of our image box. To demonstrate this I&#039;ll use 3 different examples to target images under different circumstances using the three methods of naming selectors mentioned above.</p>
<h3>Example one, targeting all images on the page</h3>
<p>If we use the element&#039;s name as the selector name, in this case img for image, then our style rules will be applied to every example of that element type on the page unless we subsequently override the rules we create here, or target individual examples more specifically. If you need to review the syntax described above before proceeding then please do so.</p>
<ol class="code">
<li><code>img {</code></li>
<li><code>width: 210px;</code></li>
<li><code>height: 150px;</code></li>
<li><code>border: 1px solid black;</code></li>
<li><code>padding: 0;</code></li>
<li><code>margin: 5px;</code></li>
<li><code>}</code></li>
</ol>
<p>The above code shows a simple example of a CSS rule set which contains all of the required components mentioned earlier. We begin with our &#034;img&#034; selector which will target all of our images. We then open the declaration block with an opening curly { before proceeding with our declarations. Although I&#039;ve separated each declaration by placing them on their own lines it&#039;s not necessary to do so, but it&#039;s helpful when reviewing and editing our rule sets as they&#039;re easier to read. The first two declarations relate to the dimensions of the content area within our box, in this case the image dimensions, but it could just as easily have been the dimensions imposed upon a paragraph of text &#8211; the same method is used in all cases. We have our width and height properties on the left separated, by a colon, from the property values on the right, and we end the declaration with a semi-colon. So the first box property that we are manipulating is the width, and we&#039;re giving the width a value of 210 pixels &#8211; the addition of a unit is important with any numerical value greater than zero, in this case we used px to establish that our units are pixels. Property three sets the border around both the contents and padding, and you&#039;ll notice that we&#039;ve given that property several values, these establish the width of the border, its colour and the line type. Later I&#039;ll give some examples of other property values that could have been set. We then have property four, the padding. In this example the padding has been set to zero, so that the border is in contact with the image, and you&#039;ll note that we haven&#039;t specified the unit of measurement &#8211; this is because a value of zero is zero regardless of the unit of measurement used, and so it&#039;s not necessary to include. Then we added our margin, with a setting of 5 pixels, before closing the rule set with the closing curly }. It&#039;s that simple &#8211; but it can get slightly more complex as we&#039;ll find out shortly.</p>
<h3>Example two, targeting groups of images</h3>
<p>There may be instances where we need to apply rules to some, but not all, images on a page. If we were to use the element name (img) as our selector name then it wouldn&#039;t be possible to do that, and so we have to create a rule set that targets our special class of images whose boxes we wish to manipulate differently to the rest. To do this we use a class. A class in CSS is a name, of our own choosing, that is identified as a class name by having a leading full stop (period), for example <strong>.specialimages</strong>. The creation of classes in this manner increases the power of CSS a great deal, giving us far more control over the elements on our web pages. Before proceeding review the previous example if you need to as the method of writing our rule set is the same, however we&#039;re going to look at how to increase the control over the box properties by manipulating them in an even more precise manner.</p>
<ol class="code">
<li><code>.specialimages {</code></li>
<li><code>width: 210px;</code></li>
<li><code>height: 150px;</code></li>
<li><code>border-top: 1px solid black;</code></li>
<li><code>border-right: 5px dotted yellow;</code></li>
<li><code>border-bottom: 2px dashed #CCCCCC;</code></li>
<li><code>border-left: none;</code></li>
<li><code>padding: 1px;</code></li>
<li><code>margin: 5px;</code></li>
<li><code>}</code></li>
</ol>
<p>As you can see, this example is clearly more complicated than the previous one and as a result begins to show the follow of including white space by separating the declarations onto individual lines. You should also note that our rule set won&#039;t target any images unless we let it know that it needs to &#8211; we do this by adding the class name to the image tag within our HTML mark-up by including a class attribute in this format: <strong>class=&#034;specialimages&#034;</strong>. That goes within the opening <strong>&lt;img&gt;</strong> and, as you can see, doesn&#039;t include the leading full stop. Besides changing the selector from targeting a HTML element name to using a class we&#039;ve also broken up the border into its four component sides and set the properties of each individually. Note the order that they appear in, I&#039;ve specifically used that order in preparation for our final example so that you can familiarise yourself with the sequence. I&#039;ve also demonstrated a couple of the other possible line types with the dotted and dashed settings on border-right and border-bottom respectively, along with a demonstration of another way of setting the colour, using the hexadecimal code #CCCCCC, and the syntax for setting no border, using none unlike the use of a zero for margins and padding, on border-left. In the final example we&#039;ll advance on some of the declarations further as well as demonstrate how to target an ID and discuss the significance of their use.</p>
<h3>Example three, targeting a single image</h3>
<p>In order to target a single image to the exclusion of all of the others, and also to override any general rules that may have been set via the img selector if necessary, we need to give it a unique ID. Doing so allows us to manipulate individual elements in isolation from other examples of the same element, this gives a tremendous amount of control and is particularly useful when used in conjunction with element positioning. As with the leading full stop present on class selectors IDs also have a special symbol which identifies them as an ID, the hash or pound symbol #. Once again review the previous example before proceeding.</p>
<ol class="code">
<li><code>#extraspecialimage {</code></li>
<li><code>width: 210px;</code></li>
<li><code>height: 150px;</code></li>
<li><code>border: 1px solid #000;</code></li>
<li><code>padding: 1px;</code></li>
<li><code>margin: 5px 2px 10px 3px;</code></li>
<li><code>}</code></li>
</ol>
<p>Although more advanced than the class example it&#039;s possible to make our rule sets less complicated by the use of shorthand on properties that allow it &#8211; which all of border, padding and margin allow. In this case I&#039;ve used shorthand on the margin to condense the property values for each side into one declaration, whereas in the previous example I used multiple declarations for the different border sides. As mentioned in example two the order is of great importance and has a clockwise sequence reading from top to right, to bottom, to left. It&#039;s clearly a lot easier to do it that way than it is to create a separate declaration for each side &#8211; however separating the border sides into individual declarations is needed to also set the line type and colour, without which the border would be invisible even though it will take up space on the page. Still with the theme of using shorthand, I&#039;ve also included a shorthand version of the hexadecimal code for black &#8211; shortening it from #000000 to #000, this works when the hexadecimal code can be divided into three groups of identical code pairs, for example #ff0033 can be shortened to #f03, but f0cd30 can&#039;t be shortened. To finish we need to know how to target our individual image containing box with the unique ID and, as with classes, this is done by including a reference to it within our opening image tag &#8211; this time in the form id=&#034;extraspecialimage&#034;, once again the leading character is dropped in the mark-up.</p>
<p>Hopefully you now have an understanding of what the box model is and how it works, which will hopefully be a better understanding than Internet Explorer versions 5.01 and 5.5 have. Both of these browsers fail to use the CSS box model correctly due to a misinterpretation of the <abbr title="World Wide Web Consortium">W3C</abbr> specifications of the CSS version 1 box model. We&#039;ll cover this, and how to fix it, in <a href="http://www.ap4a.co.uk/archives/2005/introduction-to-the-css-box-model-part-two/" title="Introduction to the CSS Box Model, Part Two" class="internal">part two</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ap4a.co.uk/archives/2005/the-css-box-model-part-1-introduction-to-the-box-model/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
