Friday, 28 October 2016

HTML Tables & Inner Styling

It is possible to create tables using HTML. The use of this could be to display a timetable on your website. To create a table, you will use the <table> tag. Every table contains Table Rows which can be created using the <tr> tag.
 You will include Table Headings within the <tr> tag, denoted by the <th> tag. Using our example, a table header would be used for the days of the week. e.g. Monday, Tuesday, etc.
Following this, you would use the <td> tag. This tag is used for Table Data. An example of this would be the listing on your timetable. e.g. Room 1 - HTML Lab.
As well as using all these tags, you can include a Caption using the <caption> tag.

Although styling is done using CSS in an external style sheet, it is possible to add style rules within your HTML page directly. This is done by using the tag <style> and inputting your style rules within it. You will then call on whatever elements you wish to style, in my case, the table, th, and td elements. You will then state what you wish to style, an example of this would be the border. Once you have decided this, you will state how you would like to style it. All of this will be contained within Curly Brackets {}. Example:
<style>
       table{
               border: 1px solid black;
       }
</style>

See the example below for using all of these tags I just mentioned.



On the image on the left you can see all the tags I talked about above. Note that I have the same number of <th> and <td> in each of the column. My style rules were declared above, within the <head> tag.
On the image on the right you can see that the <th> tag will display your text in bold, and the <td> tag will display normal text. You can also see the style rules created a border around the table, with the caption being outside the border.

No comments:

Post a Comment