Difference between csshtml element center and html Element Content Center

Source: Internet
Author: User
Css center includes two aspects: one is the center of html elements, such as div box center. The other is to center the content of the html element. For example, a div box contains some text that is set to center the text in the div. This article describes how to implement and implement the css code for the two median changes. Center p box

Center p is set for the frame Box itself. To center the webpage subject horizontally in the browser, you need to set margin: 0 auto to center the layout.

Center CSS content

If the content is centered in the same way as the DIV box, the content in the box (text, images, and other content) is horizontally centered. Use text-align: center to center the content in the HTML element. Whether you set html element tags such as p tag, h1 tag, h2 tag, and p tag, you can center the content horizontally in the box.

Instance:

Difference between css html element center and html Element Content Center

Code Nong tutorial

Code Nong tutorial

Online Testing

Summary:

  • Html element center: Set horizontal center for the frame (for example, set the DIV horizontal center in the browser for the DIV itself ).
  • Html content center: Set horizontal center for the content in the box (for example, put the DIV content into an image or text)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.