A detailed introduction to HTML images

高洛峰
Release: 2017-03-22 14:10:07
Original
1730 people have browsed it

HTML images - image tag () and source attribute (Src)

In HTML, images are defined by the tag.

is an empty tag, which means that it only contains attributes and no closing tag.

To display an image on the page, you need to use the source attribute (src). src refers to "source". The value of the source attribute is the URL address of the image.

The syntax for defining images is:

<em>some_text</em>

HTML image - Alt attribute

The alt attribute is used to define a string of prepared alternative text for the image.

The value of the replacement text attribute is user-defined.

Big Boat

When the browser cannot load the image, the replacement text attribute tells readers the information they are missing. At this point, the browser will display this alternative text instead of the image. It's a good practice to add the alt text attribute to all images on the page. This helps display information better and is very useful for those who use text-only browsers.


HTML image - set the height and width of the image

The height and width properties are used to set the height and width of the image.

The default unit of the attribute value is pixels:

Pulpit rock

Tip: It is a good habit to specify the height and width of the image. If an image has a specified height and width, the specified dimensions will be retained when the page loads. If the size of the image is not specified, the overall layout of the HTML page may be destroyed when the page is loaded.


Basic Dos and Don’ts - Helpful Tips:

Note: If an HTML file contains ten images, then in order to display the page correctly, 11 files need to be loaded. Loading images takes time, so our advice is: use images with caution.

Note: When loading the page, pay attention to the path to insert the page image. If the position of the image cannot be set correctly, the browser cannot load the image, and the image tag will display a broken image.

HTML image tag

Label describe
Define image
Define image map
Define clickable areas in image maps

The above is the detailed content of A detailed introduction to HTML images. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!