I'm trying to create a scale-able table so I put it value in %. The website works just fine but why Visual Studio counts it as invalid?
The width attribute specifies the width of the <input> element. Note: The width attribute is used only with <input type="image"> . Tip: Always specify both the height and width attributes for images. If height and width are set, the space required for the image is reserved when the page is loaded.
The width attribute specifies the width of an image, in pixels. Tip: Always specify both the height and width attributes for images.
The width and height attributes are affected in img, svg tags, those are weak kind of styling, it can be overridden by CSS. If you have assigned an img tag with the width=”500″ and height=”200″ and load a CSS width and height property for img tag like width: 400px; then that 500 will be dully 400 will effect the image.
The <img> width attribute is used to specify the width of the image in pixels. Attribute Values: It contains single value pixels which specify the width of the image in pixel. Example: html.
It might be using a set of code analysis rules that deal with best practices. According to the MDN web docs, that width
attribute has been deprecated and should not be used:
Do not use this attribute, as it has been deprecated. The rules should be defined and styled using CSS.
As mentioned, you should style your table using CSS. Apply a class to the table element and define the style as such:
HTML
<table class="my-table"></table>
CSS
.my-table {
width: 100%;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With