![]() |
|
![]() |
||
![]() |
![]() |
|
HTML Attributes and ValuesSome HTML elements can contain one or more attributes, which serve to further describe the purpose or content of an element. Attributes tend to contain information about the underlying document, as opposed to being a that data itself, for example, filename (or URL's), alignment, color, size, etc. - are all examples of information that is typically expressed as attributes. HTML attributes take the for, of name-value pairs, and are always located inside an element's opening tag. Take for example, the <tr> tag, which is used for displaying a table row, as illustrated here: Code Sample:
An HTML element may contain any number of attributes, for example, the <img> tag, for displaying images often has more then one attribute present, as shown here: Code Sample:
HTML Attribute Syntax Tip
In HTML, attribute values need not be enclosed by quotation marks, however in XHTML, they are required.
We think it's good practice to remember to use them anyway.
Each attribute name-value pair must be separated by a space. The attribute names must be unique, and the order in which they appear within an element's opening tag is irrelevant. Some attributes can accept any value at all, others are more limited. The most common limitation is know as an ennumeration, in which an attribute's value must correspond to a list of predefined values, for example, a list of colors "blue", "red", "green", etc. Many attributes require a number or percentage for their value, particularly for those describing dimensions like width and height. A numeric value never includes units. Where units are applicable, as in the "width" attribute example presented earlier, the units are understood to be pixels. HTML Attributes: SummaryIn this tutorial, we reviewed several examples which covered:
|
|
||||||||||||||||||||||||||