HTML is a markup language commonly used in web page production, the most commonly used of which is the insertion and setting of images. In this article, we will introduce how to set images in HTML, including inserting images, setting image sizes, adding image borders, etc.
Insert pictures
The way to insert pictures in HTML is very simple, you can use the <img>
tag, as shown below:
<img src="图片地址" alt="图片描述">
Among them, the src
attribute specifies the address of the image, and the alt
attribute is the alternative text displayed when the image cannot be loaded. Note that when specifying the image address, you need to put it in quotation marks, such as src="image/example.jpg"
.
Set the image size
In HTML, you can use the width
and height
attributes of the <img>
tag to Control the size of images. For example, the following code sets the width of the image to 400 pixels and the height automatically adapts to the image proportions:
<img src="image/example.jpg" alt="example" width="400">
To set the width and height at the same time, you can write it in the following format:
<img src="image/example.jpg" alt="example" width="400" height="300">
When setting the size , please note the following points:
Add image border
To add a border to an image, you can use the border
property of CSS. First, you need to set an id or class for the image, and then set the border style for it in the CSS file. Here is a simple example:
HTML code:
<img src="image/example.jpg" alt="example" id="picture">
CSS code:
#picture { border: 1px solid black; }
In this example, id="picture"## is used #Set an id for the image, and then set a 1-pixel-wide, solid black border in CSS.
border-color,
border-width and
border-style .
<img> tag and the corresponding attributes. To add a border to an image, you can use the
border property of CSS. By mastering these basic knowledge, you can easily process images in web page production.
The above is the detailed content of html picture settings. For more information, please follow other related articles on the PHP Chinese website!