1

Is there a difference between

<table width="100%">

and

<table style="width: 100%">

I know that the img need

<img width="20px">

to precalculate the space it will use. But how is it with tables?

Kani
  • 810
  • 1
  • 19
  • 38
  • 1
    Not completly they talk about img tag i was asking about table tag. – Kani Apr 09 '14 at 14:31
  • The questions aren't really a duplicate, the linked duplicate talks specifically about img tags AND which has precedence when both are present. The answers mainly focus on the precedence issue, which is totally irrelevant to this question. – jmoreno Jan 26 '18 at 19:06

2 Answers2

6

The first option is the old HTML strategy of setting properties of a table. It is deprecated because of concerns about adding "visualization" properties to your HTML code, which should focus on content markup.

The second option is the (new) CSS solution but, please, do not declare it "inline" but in a separate CSS file targeting the table element with a class or ID name, otherwise advantages are effectively null; CSS philosophy is based on separation between data and styles, so if you declare it "inline"... there is implicitly no separation.

Luca Detomi
  • 5,564
  • 7
  • 52
  • 77
2

1st example is HTML width tag, which nowadays is basically used on newsletters.

2nd example is CSS inline, not a good approach, unless you want to override some class style and you don't want to add more classes.

3rd example is like 1st example, and not necessary needs the unit measure , take a look: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Img

dippas
  • 58,591
  • 15
  • 114
  • 126
  • 2
    I recommend using a better site, like Mozilla Developer Network, or better yet, the W3C specification itself. W3Schools is notorious for being wrong. – TylerH Apr 09 '14 at 14:34
  • ya i know that, I just gave that one, because the example of there having width and height with no px or %. But I will change the link to MDN :D – dippas Apr 09 '14 at 14:38