How to center the image in html

angryTom
Release: 2020-03-02 11:30:50
Original
44041 people have browsed it

How to center the image in html

htmlHow to center the picture

1. First, we need to create a new html page.

2. Then create a new img tag in the body part and specify an image.

3. Check the effect in the browser. You can find that the picture is left aligned by default and is not displayed in the center.

4. Wrap the image in a p or span tag, and add a style attribute with the value text-align:center to the tag.

Recommended learning: html tutorial

The code is as follows:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <p style="text-align: center;">
        <img src="a.png" alt="">
    </p>
</body>
</html>
Copy after login

For more HTML tutorials, please follow PHP Chinese website!

The above is the detailed content of How to center the image in html. 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