spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / html / refactoring_html2
[next]

UNIX System Administrator - SUN Solaris, Veritas, EMC, Shell Scripting, SAN (NYC)
Next Step Systems
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume
Developer News
ActiveState Debuts Open Source Business Suite
Salesforce Offers Visual App Builder
Codesion Steps Out From CVS's Shadow


Refactoring HTML: Well-Formedness - Part 2

Elliotte Rusty Harold

Digg This Add to del.icio.us

Fill In Omitted Attribute Value

Add values to all valueless attributes.

Motivation

XHTML does not support the attribute name-only syntax.

Potential Trade-offs

Minimal. Browsers are perfectly happy to read the values you supply.

Mechanics

Omitted attribute values are fairly rare in practice. The only place theyre at all common is in forms and image maps. It may well be possible to manually fix all occurrences on a site without a great deal of effort. Alternatively, you can just use Tidy or TagSoup.

To fix one, just set the attribute value to the name. For example, change this:

into this:

Only a few elements and attributes support valueless attributes in the first place:

  • input: checked, disabled, readonly, ismap
  • optgroup: disabled
  • option: selected, disabled
  • textarea: disabled, readonly
  • button: disabled
  • script: defer
  • img: ismap, controls
  • area: nohref
  • dl: compact
  • ul: compact
  • ol: compact
  • ul: compact, plain
  • frame: noresize
  • table: border
  • marquee: truespeed
  • link: disabled
  • style: disabled
  • applet: mayscript
  • select: disabled, multiple
  • object: declare

Because many of the words involved can appear in plain text, it is not safe to use regular expressions to replace these. However, you can use a simple search to find them and then verify and fix them manually. For the attributes that aren't actually English words, such as ismap and mayscript, just search for those words. For the attributes that are, such as border and compact, use a regular expression such as this:

Then search for the case where the valueless attribute is the last attribute:

home / html / refactoring_html2
[next]


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

webref The latest from WebReference.com Browse >
Use Web Caching to Make Your Web Site Faster · Creating an Online Shopping Cart Mechanism in PHP · Log JavaScript Errors Using an AJAX-driven Web Service
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Configuring Granular Settings for a Database Level Audit · The Perils of a Web 2.0 Transition on Your Business Processes · Facebook Redesigns Site —Again — Nears 400M Mark

URL: