if we are drawing a table inside a body tag and using width as 100%, then the width of the table will be equal to the browser width. Just keep in mind, the usage of style attribute overrides any style set globally. Set HTML Table Width in Pixels
The first is to use the HTML border attribute. There are two ways in which the table/cell width in HTML pages can be defined: Fixed: Width is defined in pixels Dynamic: Width is defined in terms of percentage of space available. The style attribute specifies an inline style for an element. What is a table ? The first was published on this blog long, long ago; the second was published recently on chamaileon.io's blog.The latter is an in-depth article, I really recommend you to read that. HTML Tag Reference. The other is to use CSS. The first is to use the HTML border attribute. i.e. HTML Table Border. HTML Tag Reference. Table columns with fixed width Add .table-fixed class to the table element to set a fixed width to all of the columns of the table. You determine the width of the border using a number. You can get a quick border around your table by using the HTML border attribute. The resulting table layout is generally dependent on the content of the table. Below are some examples of applying a table border in HTML. The element is a self-closing element and you need one for every columns of you table. Below are some examples of applying a table border in HTML. Example 1 below renders a table that is 500 pixels wide and has two columns. Overflow property is used to create scrollbar in table. You determine the width of the border using a number. How to Give the Cells of a Table the Same Width in HTML (HTML/CSS) by Christopher Heng, thesitewizard.com I was asked by a visitor how she could give the cells of a table equal width, since by default, the size of the cells in all the columns changed every time she added content. Typically this is done by assigning width:100% in your CSS, but this presents a problem for Javascript since it can be very hard to get that relative size rather than the absolute pixels. A Computer Science portal for geeks. A Computer Science portal for geeks. To set the table width in HTML, use the style attribute. It will override any style set in the HTML