Saturday, January 4, 2014

Create a Table of Defined Height, Width and Alignment [HTML 03]

From the previous post you have learnt to create a webpage using HTML Codes. We will create a full website of six different pages step by step. That's why we need to know detail about table. I will discuss a lot about table and it's formatting so that you can create a full website. Lets see the codes given below.
  1. <table>
  2. <tbody>
  3. <tr>
  4. <th>
  5. YOUR CONTENT
  6. </th>
  7. </tr>
  8. </tbody>
  9. </table>
The above codes are to create a simple table of one column and one row. That means there will be only one cell. Copy the above codes and paste them into the body section (between <body> and </body>) and save that with .html or .htm extension. Later run it, you will get a table. As I have not used any border so it will be hard to find out the area of the table. So, open the .html file with notepad and use a attribute border="1" into the <table> tag. Save the file and open that again. Now there will be the border of the table. The line will look like <table border="1"> after adding the attribute.

Similarly we will add the width and height of the table by adding the attribute width="100%" and height="700px". So the first line will be replaced by <table border="1" width="100%" height="700px"> of the above codes. We have used width="100%" so that the table may get the whole space of the window when we will browse the page. We need to also use another attribute to define am alignment. The attribute will align="center" to align the table in center. Similarly we may use align="left" or align="right".

Now the total code will be ....

<table border="1" width="100%" height="700px" align="center">
<tbody>
<tr>
<th>
YOUR CONTENT
</th>
</tr>
</tbody>
</table>

Copy the above codes and paste them into the body section of the page we've created in the previous post. Then save the page and open that with a browser. The result will be like the image given below.

HTML Table,table formatting,

No comments:

Post a Comment