HTML width attribute
width
The purpose of the HTML width attribute is to specify the width of the element.
Supported elements
HTML width attribute supports iframe, img, object, table, col and colgroup elements.
Syntax
<ElementName width="value">.....</ElementName>
Where ElementName is any supported element.
Type of value
Length for all the supported elements except col and colgroup. For col and colgroup elements it can be the relative length.
Default value
There is no default value of HTML width attribute.Supported doctypes
HTML 4.01 strict, HTML 4.01 transitional, HTML 4.01 frameset. For iframe HTML 4.01 transitional.
Example of HTML width attribute with img element
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Example of HTML width attribute with img element</title>
</head>
<body>
<p><img src="../../images/w3logo5.gif" alt="logo" width="150" height="78" />
</p>
</body>
</html>
Result
View this example in a separate browser window
Example of HTML width attribute
Previous: HTML valuetype attribute
Next: HTML comments
Test your Programming skills with w3resource's quiz.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/html/attributes/html-width-attribute.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics