| Table Sizes, Borders and Alignments |
|
1-15 A 1 Discover Displayed below is the code for the tables thereafter: <html> <body> <table style="border-width:5px;border-style:solid;border-color:blue;width:100%;"> <tr> <td style="border-width:4px; border-style:solid;border-color:red;">R1C1</td> <td style="border-width:4px; border-style:solid;border-color:red;">R1C2</td> </tr> <tr> <table style="border-width:5px;border-style:solid;border-color:blue;width:40%;"> <tr>
Explain the width property: |
|
1-15 Example 1: The width of a table This example shows two different width values:
|
|
1-15 Explanation 1: The width of a table To specify the width of a table, set the width property of the width style in the table tag pair to a property value between "0%" and "100%":<table style="width:property value%;"> where n stands for a value between 0% and 100% of the page width. 100% is the maximum width available. |
|
1-15 A 2
Create an HTML file that shows these tables:
|
|
1-15 A 3 Discover The following code can be used to create the two tables thereafter: <html> <body> <table style="border-width:5px;border-style:solid;border-color:blue;"> <tr> <td style="border-width:4px; border-style:solid;border-color:red;">R1C1</td> <td style="border-width:4px; border-style:solid;border-color:red;">R1C2</td> </tr> <tr> <table style="margin-left: 60%;border:5px;border-style:solid;border-color:blue;"> <tr>
Open this file in a browser and explain the margin-left property: |
|
1-15 Example 2: The horizontal position of a table In this example, the left border of the lower table is shifted 30% to the right of the upper table's width:
|
|
1-15 Explanation 2: The horizontal position of a table The margin-left property sets the distance between the left page border and the left table border. To align a table, set the margin-left property in the table's style attribute to a value between 0% and 100%:<table style="margin-left:property value%"> |
|
1-15 A 4
Create an HTML file that shows this table, which is shifted from the left margin of the page to the right by 70% of the page's width.
|
|
1-15 Example 3: The width of a table cell In this example, the width of the left cell is 80% of the table's width:
|
|
1-15 Explanation 3: The width of a table cell The width property sets a table's width. To define the table width, set the width property in the style attribute of the table tag to a value between 0% and 100%: <table style="width:property value%"> |
|
1-15 B 1
This is the HTML for the table below:
|
|
1-15 A 5 Discover The following code can be used to create the table thereafter: <tr
style="height:50px">
Open this code in a browser and explain the positions of the table content, emphasizing the distinction between the "center" and "middle" values: |
|
1-15 Example 4: The vertical alignment of table cell data In this example, the vertical alignment of table cell data is set to bottom:
|
|
1-15 Explanation 4: The vertical alignment of table cell data To specify the vertical alignment of table cell data, set the vertial-align property of the style attribute in the table tag pair to top, middle or bottom:<td style="vertical-align:property value"> |
|
1-15 Example 5: The horizontal alignment of table cell data In this example, the horizontal alignment of table cell data is set to right:
|
|
1-15 Explanation 5: The horizontal alignment of table cell data To specify the horizontal alignment of the data of data in a table cell, set the text-align property of the style attribute in the table tag pair to left, center or right: <td style="text-align:property value"> |
|
1-15 Example 6: The 'middle' and 'center' values for the alignment of table cell data In this example, the vertical alignment is set using the vertical-alignment property, while the horizontal alignment is set using the text-alignment property:
|
|
1-15 Explanation 6: The 'middle' and 'center' values
|
|
1-15 Example 7: Justifying text In this example, the text alignment is set using the justify property value for the text-align property:
|
|
1-15 Explanation 7: Justifying text To justify text, use: <tr style="text-align:justify;"></tr>. |
|
1-15 A 6
Create an HTML file that shows this text within this table:
|
|
1-15 A 7 Discover Displayed below is the code for the table and its position thereafter : <html> <tr>
Modifying the first line as follows: <table style="margin-left:70%;border:5px;border-style:solid;border-color:blue;border-spacing:7px;">
Explain this style: "border-spacing:7px" |
|
1-15 Example 8: Setting space between cell borders In this example, the border-spacing property value is set to 10 pixels:
|
|
1-15 Explanation 8: Setting the space between cell borders To set the space between all of the table borders, set the border-spacing property in the style attribute of the table tag pair: <table style="border-spacing:property value;"> to the desired space in px. |
|
1-15 A 8
Create an HTML file with the following specifications, displaying the table thereafter:
|
1-15 A 9
|
1-15 A 10
|
|
1-15 A 11 Discover The following code can be used to create the two tables thereafter: <html> <body> <table style="border-width:5px;border-style:solid;border-color:blue;"> <tr> <td style="border-width:4px; border-style:solid;border-color:red;">R1C1</td> <td style="border-width:4px; border-style:solid;border-color:red;">R2C1</td> </tr> <tr> <table> <tr>
Explain the effect of removing the styles. |
|
1-15 Example 9: Invisible table borders
|
|
1-15 Explanation 9: Making table borders invisible To display a table without showing its borders, remove the border-style style from the table tags and table data tags.Without the border-style style, you should also remove the border-width and border-color styles. Note that the borders do indeed continue to exist - they are simply made invisible. |
1-15 A 12
|
1-15 B 2
|
1-15 B 3
|
1-15 A 13
StarfruitJuice14a.html
|
|
1-15 Explanation 10: Removing the space between the cells' borders To remove the space between the table cells' borders, set the border-spacing property of the style attribute in the table tag pair to 0px:<table style="border-spacing:0px;">. |
|
1-15 Example 10: Removing the space between the cells' borders In this example, the border-spacing property value is set to 10 pixels:
Setting the border-spacing property to 0 pixels removes the space between the table cells' borders:
|
|
1-15 Explanation 11: Combining borders into a single border To combine boders into a single border, set the borde-collapse property of the style attribute in the table tag pair to collapse:<table style="border-collapse:collapse;">. |
|
1-15 Orientation 2: Examples of the following exercise The first two examples in the following example are the same as the previous ones. They are intended to help you compare them with the upcoming third example. |
|
1-15 Example 11: Combining borders into a single border The border-spacing property value is set to 10 pixels:
Setting the border-spacing property to 0 pixels removes the space between the table cells' borders:
Setting the border-collapse property to collapse merges the borders into a single border:
|
1-15 A 14
|
|
1-15 A 15 Rereading the yellow sections
Now that you have gone through the exercises on this page, reread the yellow sections. |
1-15 A 16
StarfruitJuice15.html
|
|
1-15 Submit 1: Study motivation |
|
This page was created by Hanspeter Amend
|
|
|
Solution proposals 1-15 A 2 <html> <table style="border-width:5px;border-style:solid;border-color:blue;width:100%;"> <tr> <br><br> <table style="border-width:5px;border-style:solid;border-color:blue;width:60%;"> <tr>
<br><br> <table style="border-width:5px;border-style:solid;border-color:blue;width:20%;"> <tr>
</body>
1-15 A 4 <html> <table style="margin-left:70%;border:5px;border-style:solid;border-color:blue;"> <tr> </body> 1-15 B 1 <table style="width:60%;margin-left:20%;border:5px;border-style:solid;border-color:blue;"> <tr style="height:50px;"> <td style="border-style:solid;border-color:red;width:80%;"> 80%</td> <td style=" border-style:solid;border-color:red;"> </td> </tr> </table> 1-15 A 6 <html> <table width="50%" style="border-style: solid; border-color: black; text-align: justify;"> <tr> <td> Thinking about your website not only makes you more creative but also helps you understand how it works. Figuring out how the code you imagine fits with the website you picture makes your creative skills even better. Changing the design in your mind all the time is like practicing and getting better at being creative. </td> </tr> </table> </html> 1-15 A 8 <html> <body> <table style="width:40%;margin-left:20%;border:5px;border-style:solid;border-color:blue;border-spacing:2px;"> 1-15 A 9 <html> <body> <table style="width:40%;margin-left:20%;border:5px;border-style:solid;border-color:blue;border-spacing:2px;"> <tr
style="height:90px;"> <tr
style="height:80px;"> <tr
style="height:70px;"> </body> 1-15 A 10 <html> <body> <table style="width:40%;margin-left:20%;border:5px;border-style:solid;border-color:blue;border-spacing:2px;"> <tr
style="height:90px;"> <tr
style="height:80px;"> <tr
style="height:70px;"> <tr
style="height:60px;"> <tr> </body> 1-15 A 12 <html> <body> <table style="width:40%;margin-left:20%;border:5px;border-color:blue;border-spacing:2px;"> 1-15 B 2 <html> <body> <table style="width:70%;margin-left:20%;border:5px;border-style:solid;border-color:blue; "> <tr> <td style="vertical-align:bottom;height:70px;border-width:4px; border-style:solid;border-color:red;width:70%;">R1C1</td> <td style="text-align:right;vertical-align:top;border-width:4px; border-style:solid;border-color:red;">R1C2</td> </tr> <tr> 1-15 B 3 <table style="width:70%;margin-left:20%;border:5px;border-style:solid;border-color:blue;"> <tr> <td style="vertical-align:bottom;border:0px; border-style:solid;border-color:red;height:70px;width:70%;">R1C1</td> <td style="text-align:center;vertical-align:top;border:0px; border-style:solid;border-color:red;">R1C2</td> </tr> <tr> <td style="text-align:center;height:50px;vertical-align:top;border:0px; border-style:solid;border-color:red;">R2C1</td> <td style="text-align:left;vertical-align:bottom;border:0px; border-style:solid;border-color:red;">R2C2</td> </tr> </table> 1-15 A 13 <html> <!- - Set style attribute for the color style of the page background.
- -> <!- - Title: Set style attribute for text style. - -> <!- - Line break - -> <!- - Paragraph - -> <!- - Three row table. Set style attribute for position style and
table size style. - -> <tr> <!- - Placing the unordered list into the second row and left column
of the table. - -> <!- - Set style attribute for font styles. - -> <!- - Set style attribute for list style and font styles. - -> <!- - Placing heading, title and unordered list into the third
row and first column of the table. - -> <!- - Ordered list. Set style attributes for font styles and for
spacing style between list items.- -> <!- - Ordered list. Set style attributes for font style and for
spacing between list items style.- -> </html> 1-15 A 14 <html> <body> <table style="width:70%;margin-left:20%;border:5px;border-style:solid;border-color:blue;
border-spacing:0px; "> <tr> </body> 1-15 A 16 <html> <!- - Set style attribute for the color style of the page background.
- -> <!- - Title: Set style attribute for text style. - -> <!- - Line break - -> <!- - Paragraph - -> <!- - Three row table. Set style attribute for position style and table
size style. - -> <tr> <!- - Placing the unordered list into the second row and left column
of the table. - -> <!- - Set style attribute for font styles. - -> <!- - Set style attribute for list style and font styles. - -> <!- - Placing heading, title and unordered list into the third
row and first column of the table. - -> <!- - Ordered list. Set style attributes for font styles and for
spacing style between list items.- -> <!- - Ordered list. Set style attributes for font style and for
spacing between list items style.- -> </html> |
|