Help:Wiki University HTML-- Tables - Widths
- Nesting Lists
- Fonts - Changing
- Font Size
- Font Colors
- Font Bold-Italics
- Width and Height
- Tables - Borders
- Tables - Widths
- Tables - Captions
- Tables - Col Labels
- Tables - Cells
- Tables - Rows
- Tables - Placement
- Tables - Sorting
- Tables - Scrolling
- Tables - Col Only
- Tables - Col Spans
- Tables - Row Spans
- Infobox - Creating
- Infobox - Placing
- Infobox - If function
- Position - Relative
- Position - Absolute
This is our table from the last chapter:
- PLEASE NOTE: The width is being controlled by the size of the font and amount of text in the cells
- What if you want the table to be as wide as the page, here we use our width attribute.
- Let's say we want it to cover the entire width or 100% of the page.
The width of a table or cell can be set with either percentages or a fixed amount in pixels. A table can be, for example, 50% of the page width or 320 pixels.
- We only need to add the width attribute to our opening table tag:
- PLEASE NOTICE the semi-colon that separates the border attribute from the width attribute. Remember we always use semi-colons to separate attributes.
Here is our little table with the width attribute installed:
CELL AND COLUMN WIDTH
- The width of the cells is controlled by the text or the amount of text in the cells. The width attribute for the entire table does not make the cells equal in width. If one cell had a large amount of text in it, the other cells might be much smaller in width then in our example.
- To control the width of cells or actually the columns, we need to install the width attribute in the top cells in each column. If you are wondering why not in all cells like the border attribute, it is because the top cells seem to be able to influence the cells under it.
- Let's make our table so each of the cells is 25% of the entire width of the table in other words make all the columns the same width.
Here's the coding:
- AGAIN NOTICE we are determining the width of the columns not just the width of the top row of cells.
- NOTICE the width attribute is separated from the border attribute by a semi-colon.
WIDTH ATTRIBUTES FOR PADS AND SMART PHONES
TRY THESE OUT . . . . .