HTML5, CSS3, and JavaScript Fourth Edition

(Ben Green) #1

CHAPTER 4. HTML TAGS AND ATTRIBUTES 46


4.4.1 style=


style=specifies any CSS styling attributes that may be desired. Exam-
ple,style='color:red'. The style attribute provides immediate control
of anything that can be done using a cascading style sheet. Because it is
specified immediately at the tag, it takes precedence over anything the CSS
style sheet may say.


4.4.2 id=


id=specifies the ID of the item. Example,id=top. The id attribute gives
a unique name to the tag. Each id should only appear once on a web page.
This name can be used by the web browser, to jump to that part of the
webpage. It can also be used by CSS and JavaScript to control style and
actions or animations relating to that item.


ID values must be unique within an html page, and must start with a letter.
They can continue with letters, digits, underscores, dots (points, periods,
full stops), dashes, and colons. (Specifically, they cannot include spaces.)
There is no limit to length.


Exam Question 82(p.341):In HTML, what type of character can be first
in an id?
Acceptable Answer:letter


Exam Question 83(p.341): In HTML, what six kinds of characters can
appear after the first in an id?
Required Answer:letter, digit, dot, dash, colon, underscore


Exam Question 84(p.341):In HTML, is id=123 valid?
Required Answer:no


Exam Question 85(p.341):In HTML, is id=abc valid?
Required Answer:yes


Exam Question 86(p.341):In HTML, is id=a.b.c valid?
Acceptable Answer:yes


Exam Question 87(p.341):In HTML, is id=a-b-c valid?
Acceptable Answer:yes


Exam Question 88(p.341):In HTML, is id=ā€a b cā€ valid?
Acceptable Answer:no

Free download pdf