Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why x% is not a valid value of attribute 'width' in Visual Studio?

Visual Studio table element's width attribute

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?

like image 878
shioko Avatar asked Apr 05 '18 17:04

shioko


People also ask

What is the value of width attribute?

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.

Is width a tag or an attribute?

The width attribute specifies the width of an image, in pixels. Tip: Always specify both the height and width attributes for images.

Which tag is having width and height attributes?

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.

What is the tag of width?

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.


1 Answers

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%;
}
like image 123
nbkhope Avatar answered Sep 19 '22 08:09

nbkhope