How to Center the Content of a Web Page Using CSS

Table of contents:

How to Center the Content of a Web Page Using CSS
How to Center the Content of a Web Page Using CSS
Anonim

Do you want your website content to appear perfectly centered on the page to get two exactly identical side edges while maintaining left justified text alignment? This tutorial shows you how.

Steps

Method 1 of 1: Center the Content of a Web Page

Center Web Page Content Using CSS Step 1
Center Web Page Content Using CSS Step 1

Step 1. Launch Notepad or a text editor with similar functionality

Center Web Page Content Using CSS Step 2
Center Web Page Content Using CSS Step 2

Step 2. Create the basic structure of the web page

Center Web Page Content Using CSS Step 3
Center Web Page Content Using CSS Step 3

Step 3. Inside the tags, enter the style definition that appears in the image

Center Web Page Content Using CSS Step 4
Center Web Page Content Using CSS Step 4

Step 4. Inside the tags, insert the following 'div' tag

Center Web Page Content Using CSS Step 5
Center Web Page Content Using CSS Step 5

Step 5. Insert the content of your web page inside the tags

Center Web Page Content Using CSS Step 6
Center Web Page Content Using CSS Step 6

Step 6. Here is the finished product:

Center Web Page Content Using CSS Step 7
Center Web Page Content Using CSS Step 7

Step 7. Save the created document with the extension '.htm' or '.html', now your work is done

Advice

  • You can add the following code background-color: [color];

    within the description of the 'body' style and the 'centered' style. By using different colors for each, you can create a colored border on both sides (right and left) that will be perfectly identical.

  • Experiment with changing the page width until you achieve the desired result.

Recommended: