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 CenterCode 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)