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.
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>
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!