With HTML 4, you can specify the width of a
table using the width
attribute, e.g.:
<table width="50%">
to specify the table should occupy
50% of the page width. However, with
HTML5
specifying a table's width by that method has been deprecated. E.g., if you
check your HTML code for adherence to the HTML 5 standard with the Nu Html Checker provided by the
World
Wide Web Consortium, you will see an error similar to the following
one displayed if you are using "width=" within a table tag.
The width attribute on the
table
element is obsolete.
Use CSS instead.
From line 102, column 1; to line 102, column 68
ow:↩<table class="dlgframe" width="50%" cellpadding="1"
cellspacing="0">↩<tr>↩
You can achieve the same effect, while making your HTML code HTML 5 compliant, using the Cascading Style Sheets (CSS) code within the table tag:
Or you could include the following style section in the HEAD
section of the HTML code for the webpage, if all tables with a class of
"dlgframe" on the page should occupy 50% of the webpage's width:
<style type="text/css"> .dlgframe { width: 50% } </style>
Related articles: