How to center html text and images? What is the centering code?

云罗郡主
Release: 2018-11-02 15:09:58
Original
53499 people have browsed it

How to center text and pictures in html? What is the centering code? I believe many people who have just learned CSS will have such questions. Let’s summarize them below. Currently the latest version of HTML (HTML5) does not support the "center" tag, so you need to use CSS style formatting to center the text in your HTML5 document.

1: How to center html text? [Recommended Learning: Html5 Tutorial]

1. Open the HTML document and double-click the HTML document to open it in your computer's default text (or HTML) editor. Find the text, paragraph or other text you want to center, we add the "center" tag to the text, the syntax is:

test
, where "test" is the text. If there are labels on the text (for example, the paragraph text is "

p>"), the "center" label can extend beyond the existing labels:

Code example:

<DOCTYPE html> 
<html> 
<body>
<h1><center>欢迎来到我的网站</center></h1> 
<center>php中文网</center > 
<p1>本网站的目的是php在线学习</p1>
</body> 
</html>
Copy after login

Code display effect:

How to center html text and images? What is the centering code?

2: How to center pictures in html?

Create a new element and center the element. You can include an image within this centered element. However, it creates extra space around the element.

Start a new line of code. Start by centering the element. Enter

.

Add image code. Enter php Chinese website

We can specify the height and width of the image. Enter style="max-width:90%" width="200"> or another size of your choice, this is the end of the section that marks the image.

Use

closing tag. For example, the entire code looks like this:

<center><img src =“dancingdogpicture.gif”alt =“dance dog”align =“middle></center>
Copy after login

The above is how to center HTML text and images? A complete introduction to what the centering code is. If you want to know more about HTML5 Online Manual, please pay attention to the php Chinese website.


The above is the detailed content of How to center html text and images? What is the centering code?. 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!