'100%' is not a valid value of attribute 'width'

I got something like this:

<table id="table_itinerary" class="display" width="100%" cellspacing="0">

Open in new window


and Visual Studio prompts with a warning mentioned that: '100%' is not a valid value of attribute 'width'

It seems to work but how to fix this issue or to have a better syntax in HTML5?

Thank you.
trowaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dr. KlahnPrincipal Software EngineerCommented:
Remove the width attribute and the table will default to 100% width.
Dave BaldwinFixer of ProblemsCommented:
You must have the width of the parent element defined in order to use width="100%".  Otherwise, you are trying to get 100% of an unknown value.  Without a width spec, tables will only be as wide as the content.
Snarf0001Commented:
You shouldn't be using the width attribute at all, you should be setting in css as you asked about:

<table style="width:100%; border-spacing:0; border-collapse:collapse;">

Open in new window


As Dave said, if the width attribute is removed, the style will NOT default to 100%, it will be according to the content.
But the 100% is a bit more flexible than that, width is more forgiving than height, and anything that's block level and not floating as a parent element has an "implied" 100% width.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
trowaAuthor Commented:
@Dr. Klahn,

[quote]Remove the width attribute and the table will default to 100% width.[/quote]

This is only true if I applied the datatable js

Anyway, thanks all for the comments!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.