How to center html pictures

coldplay.xixi
Release: 2023-01-05 16:12:27
Original
59294 people have browsed it

How to center a picture in html: First create a new web page, create an img tag in the body part, and specify a picture; then put the picture in a p or span tag, and add a value of [text] to the tag -align:center] style attribute is enough.

How to center html pictures

The operating environment of this tutorial: windows7 system, html5 version, DELL G3 computer.

How to center the image in html:

First we need to create a new html page.

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

Check the effect in the browser and you can find that the image is left aligned by default and is not displayed in the center.

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

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

Related learning recommendations: html video tutorial

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