HTML5, CSS3, and JavaScript Fourth Edition

(Ben Green) #1

CHAPTER 4. HTML TAGS AND ATTRIBUTES 42


<... attribute="abc" ...>(strongly recommended)


<... attribute = "abc" ...>(not recommended)


<... attribute= "abc" ...>(not recommended)


<... attribute ="abc" ...>(not recommended)


4.3.3 Quote Marks


For an attribute value, quote marks are normally not required.


To avoid confusion, if the value itself could be misunderstood to be HTML
syntax, then the quote marks are required. These syntax characters are:
space, the three kinds of quotes (single, double, and backquote), less than
(<), greater than (>), and equals (=).


Having a space inside the value is the most common reason for needing
quotes.


Specifically, when you are just writing letters, digits, and simple punctuation
like dot (.) or slash (/), the quotes are not required. A URL does not usually
require quote marks.


When quote marks are used, they can be either single quotes or double
quotes, and must be the same before and after the value.


<... attribute=abc ...>(good)


<... attribute=a'c ...>(not allowed)


<... attribute="a'c" ...>(good)


Exam Questions: You should know whether certain characters make it
necessary to enclose an attribute’s value in quotes or not.


Spacehas special meaning in this part of HTML. It delimits things. Because
it has special meaning, it must be quoted.


Exam Question 63(p.340):If an HTML attribute’s value includes a space
does that force it to be quote marked?
Required Answer:yes


Double-quotehas special meaning in this part of HTML. It delimits a
value. Because it has special meaning, it must be quoted (using single-
quotes).


Exam Question 64 (p.340): If an HTML attribute’s value includes a

Free download pdf