HTML Course | Building Main Content – Section 2
In the last article, we began building the main section of the website and have completed the first section. Let us now move to the section 2 of Main Content.
You can see the Section 2 of the Main Content in the below image:
If you observe carefully, you can say that the section 2 is divided into three columns as shown below:
This is also referred to as 3-Column layout in terminology of Web Development.
Let’s start writing HTML for Section 2 of our Website, follow the below steps:
- Declare a parent div with a class named row.
- Declare three div’s inside the parent row div to contain three columns and assign them id’s as column1, column2 and column3 respectively.
- For Each Column:
- Declare a div with class = “column-title”. For the title of the column.
- Declare a paragraph p element for the description of the content.
- Declare an anchor tag <a> to add an external link which will be styled as a button later.
Below is the complete HTML code for the Section 2 of the Main Content:
If you run the index.html in your browser, you will be able to see something as shown below:
This no where looks close to our final Section 2 in the Main Content. Let’s start adding styles to it.
- Adding basic styles for layout: Firstly, set the overflow to hidden and add all the required margins and paddings. Next is to give the thin 1px border at the top of the section to separate it from the previous section and align all of the text inside it to center.
Add the below CSS code to your style.css:
- Aligning Columns In-line: The next step is to align all of the columns in single line one after the other. To do this, add the below CSS code to your style.css file:
- Styling the Title of columns: The next good thing to do is to style the title of the columns. To give them appropriate font-sizes and weights apart from the default values. Add the below CSS code to your style.css file:
Once you have added the above styles successfully, your Section 2 now will look something as shown below:
It looks good now apart from the buttons at the bottom. The buttons are still appearing as simple links. Let’s make them look good by adding some CSS.
To make the buttons look good, do the following:
- Remove text-decoration.
- Align text to center.
- Set the display property to “inline-block”.
- Set appropriate font-size, color and background color of the button.
- Add paddings and margins.
- Set the cursor property to pointer so that whenever the user hovers over the button the mouse pointer will change into a nice looking hand representing a pointer.
- Use the :hover selector to add styles whenever user hovers over the button.
Below is the complete CSS code for the “button” class which you need to add in your style.css file:
Now, the Section 2 of our website is complete and will look something as shown below:
- Google Chrome
- Microsoft Edge