Professional Documents
Culture Documents
ADDING LINKS
OVERVIEW
• The a element
• Mail links
Adding Links
<a> </a>
<li><a href="http://www.foodnetwork.com">The
Food Network</a></li>
Linking on Your Own Site
The target attribute in the a tag tells the browser the name of the
window in which you want the linked document to open:
target="_blank"
Always opens a new browser window.
target="name"
Opens a new window with that name and then opens all
subsequent targeted links with that name in the same window.
It may also open in an embedded frame (iframe) with that name.
Mail Links
• Favicon
Web Image Formats
• Choose the most appropriate file format for an image to keep its file
size at a minimum:
• JPEG
• PNG
• GIF
• WebP
• Can be animated
Is graphical, with flat colors 8-bit PNG or GIF PNG and GIF excel at compressing flat color.
Is a photograph or contains JPEG JPEG compression works best on images with blended colors.
graduated color Because it is lossy, it generally results in smaller file sizes than 24-bit
PNG.
Is a combination of flat and 8-bit PNG or GIF Indexed color formats are best at preserving and compressing flat color
photographic imagery areas. The pixelation (dithering) that appears in the photographic areas
as a result of reducing to a palette is usually not problematic.
Requires transparency GIF or PNG-8 Both GIF and PNG allow on/off transparency in images.
Requires multiple levels of PNG-24 or PNG-8 Only PNG supports multiple levels of transparency. PNG-24s with
transparency alpha transparency have a much larger file size, but finding tools to
create them is easier. WebP also supports alpha transparency and
may be a better option once it is better supported.
Requires animation GIF GIF is the only supported format that can contain animation frames.
APNG and WebP may be better options in the future.
Image Asset Strategy
The img element tells the browser to make a server request for
the image and display it in its place:
• Alternative text (alt text) should convey the same information and
function as the image.
• If the image is purely decorative and shouldn’t be read aloud, include the
alt attribute with an empty value:
• Consider what the alt text would sound like when read aloud by a screen
reader.
• When an image is used as a link, the alt text serves as the linked text.
• Avoid starting alt text with “An image of” or “Graphic of”.
width and height Attributes
<img src="flowers.svg" alt="" width="120" height="160">
• The width and height attributes set the dimensions of the image
on the page in number of pixels.
• They help the browser maintain space for the image in the layout
while the files load.
• Don’t use width and height attributes if you are sizing the image
with style sheets or if the size changes in a responsive layout.
• If the attribute values do not match the dimensions of the image, the
image will resize and may be distorted or blurry.
A link as image
To use an image as a link, put the <img> tag inside the <a> tag:
Example
<p>The image is a link. You can click on it.</p>
• iframes
• Video players
• Audio players
• Canvas
Window-in-a-Window (iframe)
<iframe> </iframe>
• The width and height attributes specify the size of the window in
pixels.
Embedded Video
<video> </video>
The content in the video element is a fallback for browsers that don’t
support the HTML5 video element (e.g., providing a link to the video).