Jump to content

XHTML/XHTML Attributes

25% developed
From Wikibooks, open books for an open world

In XHTML, attributes are used to give additional context or description to an element. Most commonly, you will see them as hyperlinks, but they also aid in the presentation of the text.

Common attributes

[edit | edit source]
Attribute Description
class Assigns a class to an XHTML element; used to assist in reader interpretation (such as style sheets.)
style Assigns a style to an XHTML element. This applies to one element; for multiple items or layout, you may want to use classes.
id
xml:id
Assigns a unique id to an element within the document. Used for anchor targets.
title Provides a title to an element (such as a link).
xml:lang Specifies the language of an element.

Formatting attributes

[edit | edit source]
Attribute Description
edit Used to indicate a change in text. May be "inserted", "deleted", "changed" or "moved".
datetime Indicates a time something was changed. Normally used in combination with edit attribute.
dir Direction of text, for use with left-to-right or right-to-left languages. May be one of "ltr", "rtl", "lro", or "rlo"
layout Either "irrelevant" (default) or "relevant" (as with the <pre> tag). Determines whether excess whitespace is ignored.
media Specifies the content the media is intended to be displayed on; it is ignored if it doesn't match. Defaults to "all", but may be "aural", "braille", "embossed", "handheld", "print", "projection", "screen", "tty", "tv", or other value not-yet specified.

Hyperlinking

[edit | edit source]
Attribute Description
cite Indicates that the material in question arrived from a different source.
href Indicates a destination when a link is activated or clicked on.
hreflang Indicates the language of the given link.
hrefmedia Indicates the type of media of the given link.
hreftype Descrives the type of content from the link (e.g. "text/html").
nextfocus
prevfocus
Determines the order for the elements concerning user input. Implementation specific.
target Determines the environment where the link will be opened.
key Determines the access key for the element.
targetid Used in combination with the key attribute. Specifies which element receives the event when a key is pressed.
targetrole Specifies the role of the target.
xml:base Specifies the base URL, when relative links are used in the document.
rel When used with href, identifies the relation of the linked document. May be one of "alernate", "start", "next", "prev", "up", "contents", "index", "glossary", "copyright", "chapter", "section", "subsection", "appendix", "help", "bookmark", "meta", "icon", "p3pv1" (policy reference file), "profile", "role", and "cite".
rev The inversion of rel; the document referenced by href has the designated relationship with this document.