From an accessibility
point of view, it also makes the document easier to understand for people who
use screen readers or might have the styles disabled.
??? You used less HTML, and brevity is good. The fewer bytes you have to send back and
forth between the server and the client is a Good Thing?„?. Ajax has become popular in
part because it gives you the ability to send less information (see Chapter 5). It??™s also
one of the reasons why CSS has become popular (and why I wanted to learn it). No
longer did I have to wrap
tags around everything on the page; I could use CSS
to style the entire page. Better than that, the CSS file would get cached and make every
subsequent page request even faster.
When you get into dealing with the CSS, you??™ll also discover that you can take advantage
of specificity rules: something that would be made more difficult by using the same element
for everything (specificity will be discussed in a bit).
CHAPTER 2 n HTML, CSS, AND JAVASCRIPT 17
Element Identifiers
HTML has two different attributes to identify an element: id and class.
An id attribute assigns a name to an element and must be unique on the page. It also has
strict naming conventions that must be followed. The W3C specification says the following:
ID and NAME tokens must begin with a letter ([A??“Za??“z]) and might be followed by any
number of letters, digits ([0??“9]), hyphens (???-??™), underscores (???_??™), colons (???:??™), and periods
(???.
Pages:
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60