HTML and CSS Reference
In-Depth Information
Figure 2-2. The tool tip effect of the title attribute being set on a link
The next attribute, lang , specifies what language the text within an element is writ-
ten in. This is used by some elements to render text differently based on differences in
language scripts, such as the type of quotes used. For example, the following code snip-
pet from the top of a web page would specify that the whole HTML page is written in
the English language:
<html lang="en">
Lastly, the contextmenu attribute was added in HTML5, but at the time of writing
has yet to be implemented in any released major browser. The idea is that a menu ele-
ment can be associated and displayed with a particular element by setting the element's
contextmenu to the id attribute of the menu. For any more insight into how it works,
you will have to wait for the browsers to catch up with the specification!
The id attribute is used for assigning a unique identifier to a specific element on the
page, which can subsequently be accessed using CSS or JavaScript for styling or script-
ing purposes. 2 It is a unique name you can assign to one of your HTML elements, which
you can then use to reference the element. The class attribute is used in a similar fash-
ion; however, unlike the id attribute, the same class value may be applied to multiple
elements on the page for the purposes of specifying that they have something in com-
mon (such as a particular CSS style). To summarize, the main differences between the
id and class attributes are as follows:
2 The id attribute may also be used as the target of hyperlinks. Using the id attribute for this pur-
pose is discussed in the “Hyperlinks” section in Chapter 3 .
Search WWH ::

Custom Search