tags:

views:

65

answers:

1

1) If inside CSS file we specify the following style:

td
{ text-align:center; }

While in a Html file we have

<td align=”right” … >

then value set in CSS file will take precedence over an inline html attribute and thus elements contained inside <td> cell will be aligned to the center.

a) Is same true for all html attributes? Meaning if a CSS rule and an html attribute functionalities overlap , will the CSS rule always take precedence?

BTW – I know we should usually prefer using CSS rules vs html attributes

thanx

+1  A: 

Which set of definitions, HTML attributes or CSS properties, take precedence?

The textbook answer:

CSS properties take precedence over HTML attributes. If both are specified, HTML attributes will be displayed in browsers without CSS support but won't have any effect in browsers with CSS support.

(Reference: http://www.hwg.org/resources/faqs/cssFAQ.html)

The real-world answer:

It depends, if you want to be certain for a specific attribute or set of attributes, you will have to create a unit test and apply those tests to the specific browser(s) that you want to verify for compliance with the "textbook" answer, or compliance to your specification for the specific project you are working on.

You already imply that you know certain HTML attributes are deprecated, so I will not belabor that point here.

dreftymac
" won't have any effect in browsers with CSS support" As far as I can tell, if CSS rule is specified on the parent element, then html attribute on a child element will take precedence over CSS rule of a parent element. Thus I assume it's not entirely true that on browsers supporting CSS html attributes won't have any effect?
AspOnMyNet
It won't take precedence over the **rule** on the parent element, it will take precedence over the default behavior of inheriting from the parent element.
David Dorward
thanx for helping me
AspOnMyNet