Archive Ensembl HomeArchive Ensembl Home
Home > Help & Documentation

XHTML Quick Reference

XHTML is basically HTML with a smaller list of allowed tags and stricter syntax - if you know HTML already, it shouldn't take long to master XHTML.

Syntax

  1. All tags and attribute names must be lowercase

    However attribute values can be mixed case if they are not from a pre-defined set.
    e.g. <input type="text" ... /> but not <input type="Text" ... /> (value 'type' belongs to a predefined set); whereas <a href="http://www.sanger.ac.uk/" title="Wellcome Trust Sanger Institute"> is OK (free text value)

  2. All elements which can have end tags must have end tags

    e.g. <p>Paragraph</p><p>More</p> not <p>Paragraph <p>More

  3. All elements which do not have end tags ('empty' tags) must have closing slashes

    e.g. <br /> <hr /> <img src="image.gif" width="10" height="10 alt="" />

  4. All paired tags must be nested correctly

    e.g. <p>This is some <b>bold text with <i>italics</i> inside</b>.</p>

    In addition, there are some tags that cannot contain certain other tags:

    • The <a> tag cannot contain another <a> tag.
    • The <pre> tag cannot contain <img>, <object>, <big>, <small>, <sub> or <sup> tags.
    • The <button> tag cannot contain <input>, <select>, <textarea>, <label>, <button>, <form>, <fieldset>, <iframe> or <isindex> tags.
    • The <label> tag cannot contain other <label> tags.
    • The <form> tag cannot contain other <form> tags.
  5. Attribute values must always be enclosed in quotes

    e.g. <td colspan="2"> not <td colspan=2>

  6. All attributes must have values

    e.g. <input type="checkbox" name="choose" checked="checked" /> not <input type="checkbox" name="choose" checked />

  7. Anchors used for jumping between links should have an id attribute not a name

    <a href="#foo">Go to foo</a> <a id="foo">Foo</a> Also, ids must match the pattern [A-Za-z][A-Za-z0-9:_.-]*

  8. All ampersands should be encoded as &amp;

    This includes alt text, titles and external URLs. E.g. <a href="http://www.misk.edu/genomics.php?project=cthulu&amp;id=hpl">Interesting Page</a>

    For internal links, the Ensembl server has been configured to accept a semicolon in URLs instead: e.g. <a href="/Homo_sapiens/ldview?snp=rs1154266;pop=936">

XHTML Elements and Attributes

There are a number of tags in XHTML Transitional that are deprecated in XHTML Strict and may be removed from later versions of HTML.

Deprecated presentational tags - use CSS instead!

<basefont><center><s>
<font><u><strike>
<big><b><sub>
<small><i><sup>
<tt><listing><xmp>

Deprecated structural tags

<applet><dir><menu><embed>

In practice, <applet> is the only one likely to be seen on the Ensembl website, and replacing it with the preferred <object> tag can be fiddly!

Allowed - but not supported by older browsers

<abbr> and <acronym> don't do much in most browsers and can break older ones, so these are best avoided.

Allowed tags

Just about all XHTML elements can take the attributes id, class, style and title; to save typing these out each time, the shorthand [std] is used.

There are two categories of deprecated attributes: presentational ones that can easily be replaced with CSS, which I have denoted with italics, and other attributes for which there is no straightforward replacement.

Element Allowed attributes Deprecated attributes
Principal document elements
html xmlns, xml:lang, lang version
head - -
body [std] background, bgcolor, text, link, alink, vlink
Document head
link href, type, rel, rev, media target
style type (required), media, title -
meta name, content, http_equiv
Text
div [std] align, nowrap
p [std] align
span [std] -
br [std] clear
pre [std] width, align
h1...h6 [std] align
address [std] align
blockquote [std] align
q [std] -
cite [std] align
em [std] -
strong [std] -
dfn [std] align
kbd [std] align
Rules, images, hyperlinks and image maps
hr [std] align, noshade, size, width
img [std] + src (required), alt (required), height, width, usemap, longdesc name, align, border, vspace, hspace
a [std] + href, shape, coords, type, accesskey, tabindex name, target
area [std] + alt (required), href, nohref, shape, coords, accesskey, tabindex target
map [std] + name
Lists
ul [std] type, compact
ol [std] start, type, compact
li [std] value, type
dl [std] compact
dt [std] -
dd [std] -
Tables
N.B. Note that whilst cellpadding, cellspacing and border attributes are allowable in tables, a more consistent look can be achieved using CSS.
table [std] + width, cellpadding, cellspacing, border, summary align, valign, bgcolor
caption [std] align
tr [std] align, valign, bgcolor
th and td [std] + colspan, rowspan align, valign, bgcolor, width, height, nowrap
col [std] align, valign
colgroup [std]
thead [std]
tbody [std]
tfoot [std]
Forms
form [std] + action (required), method, enctype target
fieldset [std] -
legend [std] + accesskey align
label [std] + for, accesskey -
input [std] + type, name, value, checked, size,, maxlength, src, accesskey, tabindex, alt, usemap, accept, disabled, readonly align
select [std] + name, size, multiple, tabindex, disabled -
option [std] + value, selected, disabled -
optgroup [std] + label, disabled -
textarea [std] + rows and cols (required), name, accesskey, tabindex, disabled, readonly -
button [std] + name, value, type, accesskey, tabindex, disabled
Executable content
script type (required), src, charset, defer language
noscript - -
object [std] + classid, type, data, codebase, archive, codetype, declare, standby align, width, height, border, hspace, vspace
param type, value, valuetype -