HTML5, CSS3, and JavaScript Fourth Edition

(Ben Green) #1

CHAPTER 5. IMAGE CROP AND RESIZE 50


separate closing tag required, optional, or forbidden?
Required Answer:forbidden


The commonly-used attributes of image are:


src=specifies the source of the image. This is a URL. See section 6.12
(page 68) for more about URLs. The source can be in the same folder as
the webpage (relative addressing) or anywhere on the Internet (absolute
addressing).


alt=specifies what should be used if the image is not usable. This is a
required field because some users (especially blind users) cannot see images.


Exam Question 94(p.341):For eachtag in valid HTML5, is the
“alt=” attribute required, optional, or forbidden?
Required Answer:required


Normally an image will be displayed in its natural size. This may be much
smaller or larger than you would like. Width and height are two ways to
control how the image is presented.


width=specifies how many pixels wide the displayed image should be. If
the original image is narrower or wider, it will be stretched or squeezed to
fit.


Exam Question 95(p.342):For eachtag in valid HTML5, is the
“width=” attribute required, optional, or forbidden?
Required Answer:optional


height=specifies how many pixels tall the displayed image should be. If
the original image is shorter or taller, it will be stretched or squeezed to fit.


With width and height, we are talking here about CSS pixels, not real pixels.
See section 1.2 (page 10) for a reminder about the difference.


If only one ofwidth=andheight=is specified, the other will be automat-
ically calculated to maintain the originalaspect ratio, the ratio of width
to height.


If both are specified, you can distort the image in fun ways.


Exam Question 96 (p.342): List the four commonly-used attributes of
the image tag.
Required Answer:src, alt, width, height

Free download pdf