Table of Contents
HTML Image - Alt Attribute
HTML Image - Set the height and width of the image
Basic Notes - Helpful Tips:
HTML Image Tag
Home Web Front-end HTML Tutorial Detailed explanation of basic html image knowledge

Detailed explanation of basic html image knowledge

Mar 05, 2018 pm 02:10 PM
html Knowledge Detailed explanation

This article mainly shares with you a detailed explanation of basic html image knowledge. HTML images - image tags () and source attributes (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:

<img src="url" alt="some_text">
Copy after login

URL refers to the location where the image is stored. If the image named "pulpit.jpg" is located in the images directory of www.runoob.com, then its URL is https://img.php.cn/upload/article/000/054/025/69ee4cbf3049b8bcc16a7e91b3657b16-0.jpg .

The browser displays the image in the document where the image tag appears. If you place an image tag between two paragraphs, the browser will display the first paragraph first, then the image, and finally the second paragraph.


HTML Image - Alt Attribute

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

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

<img src="boat.gif" alt="Big Boat">
Copy after login

When the browser cannot load the image, the replacement text attribute tells readers the information they lost. 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 (height) and width (width) attributes are used to set the height and width of the image.

The default unit of attribute value is pixels:

<img src="pulpit.jpg" alt="Pulpit rock" width="304" height="228">
Copy after login

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 Notes - 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

##Define imageDefine image mapDefine clickable areas in image maps

Related recommendations:
Recommended 5 articles about HTML images

About HTML images Detailed introduction

In-depth understanding of HTML images_html/css_WEB-ITnose

Tag Description

The above is the detailed content of Detailed explanation of basic html image knowledge. For more information, please follow other related articles on the PHP Chinese website!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1655
14
PHP Tutorial
1252
29
C# Tutorial
1226
24
Table Border in HTML Table Border in HTML Sep 04, 2024 pm 04:49 PM

Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

Nested Table in HTML Nested Table in HTML Sep 04, 2024 pm 04:49 PM

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

HTML margin-left HTML margin-left Sep 04, 2024 pm 04:48 PM

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

HTML Table Layout HTML Table Layout Sep 04, 2024 pm 04:54 PM

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

HTML Input Placeholder HTML Input Placeholder Sep 04, 2024 pm 04:54 PM

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

HTML Ordered List HTML Ordered List Sep 04, 2024 pm 04:43 PM

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

HTML onclick Button HTML onclick Button Sep 04, 2024 pm 04:49 PM

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.

Moving Text in HTML Moving Text in HTML Sep 04, 2024 pm 04:45 PM

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

See all articles