Progressive Enhancement Techniques 1: the HTML

Share this article

web layers
In my earlier articles, we discussed progressive enhancement and why it’s generally a better choice than graceful degradation. This is the first of a three-part series that illustrates how to build a simple tabbed box using progressive enhancement techniques.

Web Page Layers

Web pages are built in three layers:
  1. HTML defines the document content and structure
  2. CSS defines the layout and styling — it enhances the HTML
  3. JavaScript defines page functionality such as client-side form validation, animations and effects — it can enhance both the HTML and CSS
HTML is the only layer you can rely on with any certainty. Most browsers will display something — even if you are providing XHTML 1.1 content to a device that only supports HTML 3.2. The majority of browsers offer CSS but the level of support varies. Users can disable CSS or specify their own stylesheets in preference to yours. Some browsers such as screen readers or Lynx could completely ignore your CSS. Finally, JavaScript is the least reliable technology layer. Most browsers support JavaScript but interpreter engines differ and many people disable the language for security reasons. The likelihood of a user having JavaScript will vary from site to site but, in general, up to 5% of visitors will not have scripting enabled.

POSH Content

POSH is an acronym for “Plain Old Semantic HTML”. The term was coined by the microformats community, but it’s a useful concept for all developers who strive to build well-structured, accessible, semantic and valid HTML:
  • use semantic elements and attributes, e.g. h1 for your main title, p for paragraphs, table for tables of data (not presentation), etc.
  • use semantic id and class names when necessary
  • use the simplest and least amount of HTML possible
  • validate your code.
In the following example, we will build a tab box. The code is a simple client-side only widget, but the same concepts can be adapted throughout your development. Almost any control you can imagine will have a POSH equivalent.

Building the Tab Box HTML

At it’s most basic level, a tabbed box is a list of in-page links to associated content. The HTML structure could therefore be defined as follows:

<!-- tabs (links) -->
<ul class="tabs">
	<li><a href="#tab1">Tab 1</a></li>
	<li><a href="#tab2">Tab 2</a></li>
	<li><a href="#tab3">Tab 3</a></li>
</ul>

<!-- tab content -->
<div class="tabcontent">

	<div id="tab1">
		<h2>Tab 1 Content</h2>
		<p>This example uses progressive enhancement techniques to create a tabbed content box.</p>
	</div>
	
	<div id="tab2">
		<h2>Tab 2 Content</h2>
		<p>The control will work without CSS and JavaScript if necessary. Even a text-only browser such as Lynx will work.</p>
	</div>

	<div id="tab3">
		<h2>Tab 3 Content</h2>
		<p>For the best experience, users should use IE6+, Firefox 2+, Opera 9+, Safari 3+ or Chrome 1+ and have JavaScript enabled.</p>
	</div>

</div>
This page should work in almost any web browser with support for HTML 4.01 or XHTML 1.0. Older browsers will continue to display the content even if the links do not work as expected. HTML only screenshot Note: Semantic HTML purists will point out that the code doesn’t follow POSH guidelines because it suffers from a DIV-itis. I agree — none of the DIVs are required for the content. They have been added because it will allow us to create a better CSS-only solution and simplify our JavaScript code. In a perfect world, your HTML would be simple and unconcerned about layout or functionality. Unfortunately, web development is not perfect and it’s often necessary to make compromises. Adding an extra tag or two for CSS or JavaScript hooks won’t destabilize the web; just don’t do it unnecessarily. In my next post, we add a the CSS layer to make it prettier and improve the usability without adversely affecting the functionality. Resource links:
Other parts in this series: Related reading:

Frequently Asked Questions on Progressive Enhancement

What is the main difference between progressive enhancement and graceful degradation?

Progressive enhancement and graceful degradation are two methodologies used in web design. The main difference between them lies in their approach. Progressive enhancement starts with a basic, functional website and then adds more advanced functionalities for browsers that can support them. On the other hand, graceful degradation starts with a full-featured site and then strips away functionalities for older browsers. The goal of both is to provide a good user experience across all browsers, but their strategies are different.

How does progressive enhancement improve accessibility?

Progressive enhancement improves accessibility by ensuring that the basic content and functionality of a website are available to all users, regardless of the capabilities of their device or browser. This approach allows users with older browsers, slow internet connections, or disabilities to still access and use the website. It also ensures that the website is usable even if JavaScript or other advanced features are turned off or not supported.

What are the key principles of progressive enhancement?

The key principles of progressive enhancement include:

1. Basic content should be accessible to all web browsers.
2. Basic functionality should be accessible to all web browsers.
3. Sparse, semantic markup contains all content.
4. Enhanced layout is provided by externally linked CSS.
5. Enhanced behavior is provided by unobtrusive, externally linked JavaScript.
6. End-user web browser preferences are respected.

How does progressive enhancement affect SEO?

Progressive enhancement can positively impact SEO. Since it ensures that all content is accessible to all browsers, it means that search engine bots can easily crawl and index the content. This can lead to improved visibility and higher rankings in search engine results.

What are some examples of progressive enhancement in action?

Examples of progressive enhancement in action can be seen in many modern websites. For instance, a website might start with a basic HTML structure that displays text content. Then, CSS is added to improve the layout and design for browsers that support it. Finally, JavaScript is added to provide interactive features for browsers that can handle it. Each layer enhances the user experience, but the site remains functional even if a layer can’t be used.

How can I implement progressive enhancement in my web design?

Implementing progressive enhancement in your web design involves starting with a basic, functional website and then adding layers of enhancement for more advanced browsers. This means starting with semantic HTML that provides the basic content and functionality, then adding CSS for layout and design, and finally adding JavaScript for interactivity. It’s also important to test your website in different browsers to ensure it works for all users.

Is progressive enhancement still relevant today?

Yes, progressive enhancement is still relevant today. With the wide variety of devices and browsers in use, it’s more important than ever to ensure that your website is accessible and functional for all users. Progressive enhancement allows you to provide a good user experience across all platforms, while still taking advantage of the latest web technologies for users with modern browsers.

What are the challenges of implementing progressive enhancement?

Some of the challenges of implementing progressive enhancement include the extra time and effort required to design and test the website at multiple levels of functionality. It can also be challenging to ensure that the website remains functional and accessible as new technologies are added. However, these challenges are outweighed by the benefits of providing a good user experience for all users.

How does progressive enhancement relate to responsive design?

Progressive enhancement and responsive design are complementary strategies. Responsive design ensures that a website looks good and functions well on all devices, regardless of screen size. Progressive enhancement ensures that a website is functional and accessible on all browsers, regardless of their capabilities. Together, they provide a comprehensive approach to web design that ensures a good user experience for all users.

Can progressive enhancement be used with any web technology?

Yes, progressive enhancement can be used with any web technology. It’s a methodology that can be applied to any aspect of web design, from HTML and CSS to JavaScript and beyond. The key is to start with a basic, functional website and then add enhancements for more advanced technologies, while ensuring that the site remains accessible and usable for all users.

Craig BucklerCraig Buckler
View Author

Craig is a freelance UK web consultant who built his first page for IE2.0 in 1995. Since that time he's been advocating standards, accessibility, and best-practice HTML5 techniques. He's created enterprise specifications, websites and online applications for companies and organisations including the UK Parliament, the European Parliament, the Department of Energy & Climate Change, Microsoft, and more. He's written more than 1,000 articles for SitePoint and you can find him @craigbuckler.

htmlstandards
Share this article
Read Next
Get the freshest news and resources for developers, designers and digital creators in your inbox each week