-3

In html, what would be faster in terms of performance and page render time?

1) using tag attributes for tags (like adding border, valign, width, height to tables)

2) using css to define them

Thanks.

omega
  • 40,311
  • 81
  • 251
  • 474

3 Answers3

1

Given that the tag attributes for defining layout are deprecated and considered bad coding practice, it's a pretty good bet that the browser vendors are focusing their resources on making CSS perform better, and not putting any effort at all into making the tag attributes any better.

In addition, if you have your layout defined in a separate CSS file to your HTML, then you will definitely benefit from performance benefits over inline styles or tag attributes when loading multiple pages, since the CSS file can be cached by the browser and doesn't need to be downloaded multiple times.

Spudley
  • 166,037
  • 39
  • 233
  • 307
0

one of the benefits of using CSS is to separate the structural markup from the formatting and layering of the page. so you should always use CSS to format elements and not the attributes

Mi-Creativity
  • 9,554
  • 10
  • 38
  • 47
  • but in terms of speed, is it the same or does css make it faster? – omega May 13 '13 at 16:24
  • Especially for more than one page, CSS performance over html attributes is beyond dispute, for a website of tens of webpages, imagine the browser read formatting attributes in everysingle page vs browser reads the CSS, also for one page if you have duplicated style for divs of table cells same can be said – Mi-Creativity May 13 '13 at 16:29
0

Most HTML style attributes (besides style) such as border are deprecated, and are never good practice. CSS requires less code, and can apply to all elements of a class, id, tag, etc. The only performance issues between style and CSS are about the amount of code to download. If you have multiple pages using the same style, CSS won't need to download on the second page opened by the user, as it would be cached already.

Mooseman
  • 18,763
  • 14
  • 70
  • 93