How to set table width in HTML?

HTMLWeb DevelopmentFront End Technology

To set the table width in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML <table> tag, with the CSS property width. HTML5 do not support the width attribute of <table>, so the CSS property width is used with the style attribute to set table width.

Just keep in mind, the usage of style attribute overrides any style set globally. It will override any style set in the HTML <style> tag or external style sheet.


You can try to run the following code to set table width in HTML. We’re also using the <style> tag and the style attribute to style the table borders

<!DOCTYPE html>
         th, td {
            border: 1px solid black;

      <h1>Programming Languages</h1>
      <table style="width:100px; border: 1px solid black">
            <th>Release Year</th>


Published on 01-Feb-2018 06:53:03