Home >Web Front-end >HTML Tutorial >How to center html text and images? What is the centering code?

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

云罗郡主
云罗郡主Original
2018-11-02 15:09:5853567browse

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>

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 height="200" 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>

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!

Statement:
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