Best practices: keywords in alt attributes

This is certainly a subject that I’ve covered before — in fact, it’s something I would hardly choose to cover yet again if it didn’t continue cropping up as an important issue. The use of text in alt attributes is an extremely sensitive subject.

Today, the good folks at SEOmoz published an extensive article documenting their statistical findings on web site ranking factors, as gathered from the data in their LinkScape analysis tool. It’s a good article, and demonstrates some interesting results they’ve garnered from the data available in the extensive LinkScape database.

One of their major takeaways in the article was a little disturbing to me.

Alt attributes of images are probably pretty important places to use your keywords[.]” Explaining (Some of) Google’s Algorithm with Pretty Charts & Math Stuff, October 22nd, 2009

I’m not in anyway disputing their results; their data indicates that placing keywords in alt attributes is of benefit to search engine rankings. Whether that’s true or not is irrelevant to me; I simply want to discuss how this information should be best used.

SEOmoz, of course, is a company dedicated to the study and practice of search engine optimization and marketing. Their goal is to learn what they need to know in order to best put into practice the promotion of web sites. That’s great. My goal, however, is to make sure that users with disabilities are able to use and access web sites successfully without having to jump through unnecessary or unhelpful hoops along their way.

This is a particular case where the SEO method must be used cautiously and selectively if at all. What I want to convey in this article is the fact that while using keywords in alt attributes may help your web site rank, it can also result in a significantly less accessible web site, if applied poorly.

What’s the problem with alt attributes?

While sighted users will never even be aware of an alt attribute value in normal web browsing, screen reader users depend on them. Excess verbiage can render an image-based menu unusable, as I observed in a recent site review at Practical eCommerce. The same unnecessary use of keyword terminology in contextual images can easily confuse or distract a user; and the use of keywords with spacer or ornamental images can cause a web site to be completely unnavigable.

It’s all a question of information overload: practically speaking, if a web site uses images to convey information, a screen reader user can’t disable them without rendering the web site unusable. If the site also fills other images with extra text, the same user may be overwhelmed by an unnecessary volume of keyword phrases.

The SEOmoz report does continue to remark that “Keyword stuffing may be holding you back,” and the overuse of keywords in alt attributes can certainly qualify as keyword stuffing.

You shouldn’t take away from this article that using a keyword in an image alt attribute is totally unacceptable. That’s really not the case: just be selective. I wouldn’t condemn you for using the text “About ProductName” instead of “About” for a navigational image, or using a sensible alt attribute for a contextual image, such as “Woman using our ProductName.” Just remember that keyword stuffing is keyword stuffing, wherever you put the words.

And never place any value in the alt attribute for a purely decorational or spacing image. Please. Just an empty attribute.

How NOT to use Post meta fields in WordPress Themes

A little while ago, while working on a site built by another developer, I came across this rather interesting example of how to use custom fields badly in a WordPress theme (abbreviated for, well, brevity):

(The original also did this for meta keywords and meta descriptions — but the demonstration of this “logic” only requires one field.)

 
<? if (is_front_page()) { ?>
	<title>Handwritten title</title>
<? } elseif (is_page("page-name")) { ?>
	<title><?= get_post_meta(334, 'meta_title', TRUE); ?> | <? bloginfo('name'); ?></title>
<? } elseif (is_page("page-name-2")) { ?>
	<title><?= get_post_meta(383, 'meta_title', TRUE); ?> | <? bloginfo('name'); ?></title>
<? } elseif (is_page("page-name-3")) { ?>
	<title><?= get_post_meta(381, 'meta_title', TRUE); ?> | <? bloginfo('name'); ?></title>
<? } elseif (is_page("page-name-4")) { ?>
	<title><?= get_post_meta(383, 'meta_title', TRUE); ?> | <? bloginfo('name'); ?></title>
<? } elseif (is_page("page-name-5")) { ?>
	<title><?= get_post_meta(387, 'meta_title', TRUE); ?> | <? bloginfo('name'); ?></title>
<? } ?>

And so on. For approximately 40 separate pages. It made my brain hurt. For reference, the exact same thing — for all pages on the site — could have been accomplished (with better fallback conditions, in fact) with this code:

 
<?php if (get_post_meta($wp_query->post->ID, 'meta_title', true)=="" && is_page() ) { ?>
	<title><? wp_title('|', true, 'right'); ?> <? bloginfo('name'); ?></title>
<?php } else { ?>
	<title><?php echo stripslashes(get_post_meta($wp_query->post->ID, 'meta_title', true)); ?> | <? bloginfo('name'); ?></title>
<?php } ?>

Now, the original code may actually look cleaner — it does, after all, have fewer functions and fewer variables. However, the second example is a hell of a lot more maintainable.

If you add a new page to the site in the first example, you have to:

  1. Create the new page.
  2. Add a custom field with the title.
  3. Check the new page’s ID.
  4. Find the theme file which contains the meta data references.
  5. Add a new line in the elseif loops which references your new page first by slug and then by ID

With the second example, you simply:

  1. Create the new page.
  2. Add a custom field with the title.

No coding, no PHP, no editing themes — it just works. Well, isn’t that handy? This is just basic good coding practice: make your code reusable. There’s absolutely no reason to code something into your WordPress Themes which is not readily transportable unless you’re doing yourself a favor by avoiding an unnecessary server call by hard-coding the site name or other known elements.

The basic difference between these two examples is simple: the first requires you to hard code the ID and page slug for each example; the second grabs the post ID from the existing post object. The second example also has a fall-back if no information has been entered in a given custom field — which is lacking in the original code.

Word to the wise: save yourself some work!

Best Practices in Web Development: Part 4

  • Part 1 (Contracts, Site Requirements,Information Architecture)
  • Part 2 (Hosting and Security)
  • Part 3 (Navigation, Scent)
  • Part 4 (Semantics, Structure vs. Design, Universal design)
  • Part 5 (Interaction, Errors, and Administration)

So, we’re finally getting to the meat of best practice web development. This is what people are usually thinking of when they ask about best practices in web design or web programming: actually building the web site itself.

Web design best practices encompass a wide range of needs — everything from the visual look of the design and use of well-chosen markup to the implementation of alternate styles for mobile devices or print shows up in this area. Covering it in one article is, perhaps, ambitious. Fortunately, I’ve written on parts of this subject frequently in the past, so I’ll be providing a lot of links.

It’s important for best practices to clearly separate the structure of your web design (the internal labeling and definition of page elements) from the design elements (the appearance of these elements.) In the last article in this series, I discussed a few key elements of design: not in terms of color, layout, or typography, but in terms of communicating information.

Best practices ultimately leads to creating a universal or accessible design, and this practice hinges on two key concepts: web semantics and the separation of your structure from your design.

The Semantics of HTML

You can argue for days (or years, if you take look at the search results for “html semantics” or “web semantics”) on the detailed semantics of how HTML tags should be used. I’ve written on this several times, myself, including articles discussing the value of empty elements, the age-old debate between table-based or CSS layout, among many others.

Semantics are very important. However, when you really look closely at HTML you’ll inevitably notice that it’s not a strongly semantic language — the mark-up language doesn’t even come close to describing all possible uses of the tags. Many tags end up inevitably serving multiple functions.

So what web semantics really require is interpretation. The HTML specification provides one version of this interpretation, with suggested uses and meanings for elements. I’ve provided my own interpretation, as well. There are without question differences of opinion between those documents.

Obviously, you can argue very convincingly that any interpretation which disagrees explicitly with the HTML 4 specification is wrong. Feel free. The core of best practices in web semantics is to use them and make decisions: it’s about thinking, not specific rigor.

We need to differentiate, however, between the semantics of HTML and web semantics. The semantics of HTML are specific and defined: meaning as applied to the elements of HTML. This is a finite list of items, although the complete definition of meaning is less so. Web semantics, on the other hand, describe the application of meaning on the web. This is a more global concept, and applies to all aspects of your web development process.

Web semantics includes everything used to add meaning to your site, providing better comprehension of code and content. Using describe class and ID naming conventions, descriptive function names in server or client-side scripting, or providing helpful comments within your code can all be considered points of web semantics. Best practices means providing a site which is meaningful in both the front and back end.

For specific suggestions about element use, refer to my guide to semantic HTML.

Separation of Structure from Design

This is such an old question to harp on, but the importance of separating the organization of your page from the way it looks has never really flagged.

At a superficial level, it may appear that any markup you use has an effect on the appearance of your site. After all, there’s a clear visual difference between unstyled text marked as a heading and unstyled text marked as a blockquote! However, this visual difference only truly exists because the description “unstyled” is truly a misnomer.

If you disable stylesheets on a web site, you’ll see an extremely plain view of the site. It is not precisely “unstyled,” however — the design has simply been reduced to the default styles applied by the browser. In general, every browser has very similar defaults — but they’re not exactly the same. This is one of the reasons that it’s common to begin a stylesheet with a set of reset styles.

If you conscientiously remove the browser default styling, it can make your own development easier: the slight differences between browsers can then be ignored.

The point is that you should never place anything in your markup which exists purely to create a different appearance. Attributes or tags which define font faces, colors, or styles are obvious problems — but the use of small or strong can also be problems. It’s not that you should never use small: but your use of the element shouldn’t depend on the text being rendered smaller than the surrounding text.

It might not happen, after all.

This is one of the key complaints about using tables for design layout. A table is designed to organize information by providing easy access to it in a matrix. The columns and rows visual appearance of a table is a formality used because it is an expected way to view this type of data organization.

When you take a table and use it to layout your design, you are violating the separation of structure from appearance: your design is now dependent on the default organization of tables. Should somebody attempt to re-organize your table (for example, to linearize the information,) they may encounter a radically illogical data structure.

Fundamentals of Universal Design for the Web

The goal of universal design is very simple: make the information in your website available to every person or device which attempts to access it. This includes mobile devices, search engines, assistive technology, disabled users, and standard desktop browsers.

Universal design is where we bring everything above together. Attention to web semantics and a strong separation between structure and design give your web site at least a fighting chance of being universally usable. Obviously, you can still screw things up!

In the same way that following web standards doesn’t mean that you’ve made a web site accessible, following best practices for general web development doesn’t mean that you’ve made a site which will be great on a hand-held device or with a screen reader.

Different devices (like people) have different special needs.

Creating a web site which is truly universal requires you to be aware of the special needs of every device you’re working for — but a few basic principles will get you 95% of the way there.

The Principles of Universal Design provided by The Center for Universal Design at North Carolina State University are a good guideline for thinking about universal design. Although these principles are truly designed to be universal, in that they are intended to be applied well outside the realm of web development, the basic principles are sound in any context.

If you break the concept of universal design down to a single core issue, it could be that dependencies break access. Whenever you set up a situation in which a specific technical or design element must be present (a dependency on Javascript, a requirement that a control matches the description provided, or a requirement that a user must see a given image, for example,) then you are creating the potential for design failure. Avoid creating anything which depends anything out of your control.

Knowing what is and isn’t in your control (and, more importantly, what seems like it’s in your control, but really isn’t) is critical to best practices in web development. Acknowledging that although you can set the color of the text, you can neither guarantee that a visitor will be capable of seeing that color nor that the text will in fact be that color at the point that a visitor sees it is a critical step in understanding universal design.

Best Practices in Web Development: Part 5 (published on Friday, September 5th) covers interaction design, error management, and long-term site administration.

Best Practices in Web Development: Part 2

  • Part 1 (Contracts, Site Requirements,Information Architecture)
  • Part 2 (Hosting and Security)
  • Part 3 (Navigation, Scent)
  • Part 4 (Semantics, Structure vs. Design, Universal design)
  • Part 5 (Interaction, Errors, and Administration)

Once you’ve established your needs document, you should take the time to pick the right server set-up. Different sites need different services — but the right hosting package should always offer certain key elements. Hosting is an integral part of good web site performance, so you should pay close attention to what’s offered.

Hosting and Web Serving Expectations

Although a lot of what I discuss here primarily effects you as a developer, there are always corollary issues: the more time you spend dealing with problems, the less time you’re spending making sure everything else is done right. A slow server is frustrating to your users. Catching these problems in advance can save a lot of everybody’s time.

Big hint: the most important issues aren’t bandwidth, disk space, or cost.

Although making sure that your hosting offers sufficient bandwidth, disk space, and doesn’t break the bank is obviously important, it’s more important that you can do everything you need to with your hosting.

  1. Is your web hosting adaptable? Can you easily change your services as your needs change? It’s not uncommon for a hosting company to only offer a couple of plans — if your site grows, this means you’ll need to change hosts. While this isn’t exactly the end of the world, it’s an inconvenience you shouldn’t need to deal with. If you pick the right host to begin with, you’ll be able to move up the scale as you grow. Give some thought to your need to scale, however – if you’re creating a small website for your local restaurant, it’s unlikely that your site will grow significantly.
  2. Are there “invisible constraints” imposed on your hosting? This is a nasty one, and can be very difficult avoid — but if you know a few key questions to ask, it can help. Among the problems I’ve seen are limitations on the number of emails sent per hour (50 — impossible for the company of 12 who used this hosting,) server process constraints which caused sites to be abruptly shut off because they exceeded a maximum percentage of processor use, and restrictions on use of server-side programming such as not permitting scripts to send e-mail.
  3. Do they have current version script or database engines? Is your hosting using older versions of PHP, Perl, or other server side scripting languages? Yes, this may not effect you most of the time. However, when it does you’ll be very frustrated.
  4. Do they offer URL Rewriting support? One of the main reasons I frequently recommend that my clients use Linux/Apache based hosting is in one word: .htaccess. Admittedly, there’s a lot more to .htaccess than a few redirects and some URL rewriting, but that is an extremely key functionality. With Windows hosting, URL rewriting can be available through ISAPI Rewrite…but it’s along the lines of “pretty much always” with LAMP hosting and “maybe sometimes” with Windows.
  5. Are databases readily available? Whether it’s MySQL, Posgresql, or anything else, databases are a key element of modern web development practices. If databases aren’t readily available from a hosting company, they shouldn’t be in the running.
  6. Are their servers snappy? It’s nothing special to offer vast tracts of storage space or gobs of bandwidth. Most of the time, hosting services are gambling that the majority of the 400 sites on a server will only use 10-50 Mb of the 100 Gb of storage they’ve been allowed. Realistically speaking, most sites are very small — hosting companies can easily get away with this. However, no hosting company can get away with slow servers. If you can check the server statistics, that’ll help you know what you’re getting into.
  7. What’s their backup policy? Does the company offer backup service on your files and databases? How easily available are the backups? How frequent are they? In case of an emergency, how long would it take to restore your website?
  8. How’s their support? The single most important element from your hosting company. Period. Quick response times, professional attitude from the support team — written messages using full sentences, spoken interactions easy to understand, etc. Good support should completely read your request and respond to what you’ve said, rather than guessing at the problem from the subject line.

If you don’t have a strong foundation for your web site, you’re going to run into some trouble later on. Of course, it’s a regular event to have to work on sites where you had no say in the hosting. Sometimes, that won’t be a problem. You may need to work with an unfamiliar set up, but the hosting itself will be entirely adequate.

Sometimes, it’ll be incredibly frustrating.

Be prepared to discuss changing hosting with your clients — prepare your arguments and know the issues. With truly inadequate hosting services, you might be prevented from doing your job well.

Introducing Web Security

I didn’t mention looking at your host’s security policies and background above. That’s largely because this is an issue that goes well beyond being one of a checklist — this is a core issue for web site best practices.

I also didn’t mention it because there’s little point in asking. No host is going to tell you that they don’t really pay attention to security and have regular problems! Similarly, many hosts won’t tell you any serious details about what they’re doing to protect your security — this is, itself, protection against social hacking; but it could also mean that they don’t know what you’re talking about.

Ultimately, you can’t expect perfect security on any shared server environment to be made available by default. When a hosting company needs to make a generalized environment available which will support a wide variety of software and scripting languages simultaneously, they’re unlikely to be able to lock things down the way you might prefer.

This isn’t to say that you should ignore issues of security when you’re selecting a web hosting company — by all means, find out whatever you can! Look for reports of security violations; complaints from customers who’ve been hacked, etc. It’s good to know. However, more important is knowing what you can do to increase the security of the server for your own use.

  1. Can you use php.ini (or equivalent) to customize settings? If a host doesn’t permit you to change their default settings on an account specific basis, that’s not a particularly good sign. You should check and make sure that their reason isn’t because they’ve already maxed the security and they don’t want anybody weakening their protection; but it’s always helpful to be able to customize your needs.
  2. Can you restrict access to administrative pages? It’s frequently a good idea to restrict access to admin areas fairly stringently. Personally, I usually restrict by IP — only people at the client’s office or home (whatever’s relevant) have access to the administrative areas at all. This can help crack down on problems.
  3. Can you see other user’s accounts? This is an ugly one. Logging into an account and seeing other user accounts means just one thing: they can see yours. This hosting service is obviously not separating accounts appropriately.
  4. Is SSL encryption available? Not every hosting service supports SSL. If you don’t have the option for secure sockets layers, e-commerce is out of the question right away. Even if you don’t think you’ll need it, you might want to avoid any service where it’s not even an option.

A significant part of web site security is related to the scripts and software you install on your site (which will be addressed later); but even before you’ve put a file on the server, there’s potential for security problems. It’s worthwhile to take a close look at potential security problems before getting too far into a project. Hardening your security may not be a priority now, but if you don’t even have these basic options you’re walking into trouble.

Web Development Best Practices: Part 3 (published on Friday, August 29th) covers navigation design, and scent of information. and canonicalization.

Best Practices in Web Development: Part 1

  • Part 1 (Contracts, Site Requirements, Information Architecture)
  • Part 2 (Hosting and Security)
  • Part 3 (Navigation, Scent)
  • Part 4 (Semantics, Structure vs. Design, Universal design)
  • Part 5 (Interaction, Errors, and Administration)

This is the beginning of a five-part series highlighting the entire process of developing web sites for clients. Best practices don’t just start with construction: for a small business or independent contractor, they start long before that. Through the course of these articles, I’m going to cover issues including:

I’ll probably touch on other issues as I think of them or they appear relevant, but these 15 points will be the bulk of the article series. Although these articles are written as if the actions are performed in a strict chronological sequence, it’s important to realize that the real process of building a web site is much more fluid than any written description. Some issues can be dealt with at any point in the process, others need to be addressed repeatedly — don’t take the order I’m writing in as any kind of commandment!

Preparing a Contract

Your project starts with a contract. Before the contract is created, there may be a variety of proposal aspects — either the client delivered a request for proposals, requested your services specifically, or chatted you up in the pub…but the project doesn’t start until you have a contract.

There are good ways of going about contracting a project, and there are bad ways — this is well outside my area of expertise, but it bears mentioning: don’t work without documentation, however casual.

Now, one of the challenges of establishing a work contract in many web development projects has to do with how much work you should really do prior to going under contract. There’s a bit of a Catch-22 in place purely by the nature of the process: in order to establish an effective and project-specific contract (which you should have,) you need to undergo a discovery and requirements phase. However, this process is time-consuming. You should really only undergo this process when you’re already under contract!

Hence the establishment of a contract with two parts: the first part, signed prior to discovery phases, should establish the terms of discovery and requirements establishment, and note that the complete terms of the contract will be appended in a separate appendix following the discovery phase.

Now, this isn’t altogether necessary for small projects: a basic website can usually be estimated without a complex process.

Regardless of the scope of project, there are various terms which should always be covered in your contract:

  1. The scope of work: what’s included in this contract.
  2. The process for extending the contract, should additional requirements be established. (It WILL happen.)
  3. Estimate of costs with a statement of the terms of the estimate.
  4. Notification of late payment fees and deposit required.
  5. Ownership of end products. By default, your design work and other materials produced by you in the course of a project are yours. However, it’s a good practice to turn copyright ownership over to the client. Many clients will require it!
  6. Responsibility for creation or purchase of content: video, audio, photographic, written.
  7. Definition of the completion of the contract. (I usually specify the launch of the site.)
  8. Terms of maintenance, warranty coverage, correction of errors.

In addition to these issues, you should give a close read to a few articles by Sarah Bird at SEOmoz. She’s published several articles recently on contract clauses she recommends — although she’s speaking from the perspective of an SEO firm, most of these issues are highly relevant to a web design and development company as well!

  1. Limited Liability Clause
  2. Indemnification Clause
  3. Opportunity to Cure” Clause
  4. Manage Client Expectations: Include a Warranty

Establishing Site Requirements

Before spending any significant time working on any development aspect of a project, you should sit down and establish a list of site needs. (Actually, you can do this standing, too.) Sometimes clients have little concept of what their web site can do; sometimes they have totally unrealistic concepts of what you should easily accomplish. Either way, you need to sit down with them and find this out!

  1. What does the site need to do for them? Find out what business model this site will be reflecting. Is it advertising driven? Sales driven? Lead generation?
  2. What is their plan for growth? Do they intend to build a community around their business? Will they be offering online support for products or services? Is AdSense all they need, or do they need to be able to manage advertising at a more granular level?
  3. What kind of dynamic information might the site be able to offer/use? Will the site generate an RSS feed? Will it be articles, product information, service updates — or all of the above? Do they want to import information from an external source?
  4. What will their relationship be with their user base? Will the site be exclusively used to allow visitors to communicate to the business, or will it be a two-way conversation? Will they offer additional features for their users — widgets for their own websites, applications, etc.?
  5. What kind of site integration might be required? Do contact forms need to connect with a pre-existing database? Will integration with existing business systems be part of the process?
  6. Who will be responsible for updating the site? Do they have a professional web person to deal with updates? Will you be expected to take that on? Will they be taking care of it, but with untrained support staff? Do content edits or new content items need to go through editorial review?
  7. What kind of media might they use on the site? Images and text can be assumed, but what about audio and video? Streaming or static? Do they have the facilities or personnel to take care of captioning and transcription?

Now, the vast majority of sites require very little of this. A standard site might consist of a blog, 5-20 content pages, and a contact form. However, it’s always better for your sanity — and your contract — to have any additional needs figured out in detail before any work is done.

Once you’ve established what is required from a functionality perspective, you can sit down and convert that into a technical requirements document, specifying software required, custom programming to be done, programming languages required, databases needed, and any external information the client will need to supply.

Information Architecture

With this information, you can dive into planning your information architecture. Information architecture is, on a grand scale, a rather theoretical concept of modeling the organization of information. However, from a practical perspective, information architecture is the process of deciding how to organize the documents on your site. Depending on the type of information stored, the organization of the documents may be radically different.

The most important thing about information architecture is to think like a visitor: somebody who doesn’t already know everything about the site. This is one of the reasons it’s best to deal with content organization early in the process: you can think about content in the abstract, rather than thinking about the actual content documents you’ve spent the last month dealing with in reality.

Considering the documents in the abstract allows you to easily focus more on issues of content relationships, subject areas, and organizational logic instead of getting wrapped up in notions of familiarity.

I can’t really tell you how to organization your information — it’s fundamentally an issue of content categorization and labeling, and will depend tremendously on the information you’re working with. You can organize by type of information (Photos, Video, Articles, etc.); you can organize by section (About the business, Services offered, Contacting us, etc.). You can do both, and cross-reference between sections — it depends on your needs and the needs of your users.

Information architecture doesn’t merely apply to the organization of pages and sections of your site, however: it also applies to the organization of information on the page. This is equally important, allowing you to generate a logical map of information on the page. This will be covered in more detail in a later article in the “Best Practices” series, however!

Web Development Best Practices: Part 2 (published on Wednesday, August 27th) covers hosting expectations for a high-quality web site and introduce issues of security on the web.

Why use semantic HTML?

This is part 1 of 2. Part 2 is my Guide to the use of Semantic HTML Elements

I’ve seen a lot of articles discussing the importance of HTML and XHTML semantics. I’ve seen articles describing what it means for a document to be semantic. Most of these articles, however, don’t provide a serious overview of what HTML elements actually may be considered semantic — and what those semantic elements actually mean.

And, even more particularly, why it matters.

Semantics is an erudite area of study. Literally, semantics can be fairly defined as the study of meaning in communication. Communication can readily be extended to cover symbolic notations, representations of language, organization of language, body language and information structures. In developing a web page, we are organizing a means to communicate the content of that page: ideally, we are organizing the page in such a manner that it will be understood regardless of the method by which the page is accessed. It should be equally understandable whether seen, heard, or felt.

The semantics of HTML structure, then, are clearly an important part of web design. Sending mixed signals to the user agent or the user by using a blockquote purely for it’s native indentation is an abuse of semantics: even the visual impact is dependent on the assumption that user agents will consistently render a blockquote in an indented manner.

It’s not precisely an issue that you’ve used a semantic element for presentational means, because, in fact, you’ve done more than that: you’ve presented a block of text which is not quoted material as if it were.

Semantic elements of HTML carry meaning regardless of your knowledge of that meaning. The result is that the misuse of an element creates the potential to mislead or confuse an end-user.

The most obvious examples in common use are those which make use of elements with semantic meaning which also offer a browser-contributed default presentation in order to use that presentational style. The blockquote example above is not uncommon; similarly, the use of empty p elements to create extra white space or heading elements used as a questionable SEO technique in substitution for normal paragraphs.

Other examples which bear mentioning include the use of empty anchor elements to trigger Javascript events — in this case, it’s partially a limitation of the identity of an anchor element, but an empty anchor element should always be considered an error, as it results in a behavior-less anchor if the Javascript is not available.

Now, you may point to the following paragraph, from the HTML 4.01 specifications, as a response to my opinion:

Authors may also create an A element that specifies no anchors, i.e., that doesn’t specify href, name, or id. Values for these attributes may be set at a later time through scripts.

The fact that it is allowed by the specification does not make it a best practice. With all due respect to the W3C, this should not be permitted. For reference, the HTML 5 specification currently reads:

If the a element has no href attribute, then the element is a placeholder for where a link might otherwise have been placed, if it had been relevant.

In addition, although I won’t quote everything, the specification states that an anchor which does have the href attribute must specify a URI as the value of that attribute. It appears to essentially state that an anchor element should have no semantic meaning if the href attribute is not set and valid. But I could be wrong.

The best means to avoid the misuse of elements is to have a clear understanding of when and why a given element should be used in web development. To hopefully expand on your knowledge in that respect, I’m attempting to provide a semantic guide to HTML elements for your reference and rich disagreement.

Be aware, however, that semantics are largely a matter of opinion. It’s not a question of blindly following the guidelines set by a group; it’s a question of interpreting those guidelines to the best of your ability and belief. This guide reflect how I think HTML elements should be used; and I welcome your opinions.

Other HTML Semantics Articles

Pseudo-Accessibility: Reinventing the Wheel

In my last post, Accessibility and Client Expectations, a major point was on the practice of implementing accessibility as a site “add-on,” rather than developing a web site from the ground up with accessibility in mind. Some of the features which are implemented in this manner fall into a gross category I’m inclined to describe as “pseudo-accessibility.”

In general, pseudo-accessible features are those which:

  • Solve the symptom, not the problem.
  • Create additional accessibility problems in their implementation
  • Reinvent the wheel by duplicating browser functionality

Read more: Pseudo-Accessibility: Reinventing the Wheel

Page 1 of 11

Return to Top