HTML <Table> Width Attribute

The width attribute is used to change the width of table, it tells the browser how much horizontal space should be covered by the table. The width attribute can support values in pixels and percentage but its a good practice to use percentage instead of pixels. Assigning values in pixels is not suggested as the computers have different resolution setting, so it may create problems.

 

Here is the HTML code for setting the width of table in percentage using the table width attribute.

<Html>

<head>

<title>

</title>

</head>

<body>

Table with width of 50 percent which means it cover half horizontal area of browser

<table border="1" width="50%">

<tr>

<td>

Country 

</td>

<td>

Currency

</td>

</tr>

<tr>

<td>

US

</td>

<td>

US Dollars

</td>

</tr>

<tr>

<td>

Canada 

</td>

<td>

Canadian Dollar

</td>

</tr>

</table>

</body>

</html>

The html code will show the below result on browser.

image

Tags: , , , ,

Author: Revo

Share This Post On

Submit a Comment

Your email address will not be published. Required fields are marked *

two × 2 =

 

Pin It on Pinterest

Shares
Share This