2

I need to know if we apply some properties in both html and css for same elements , which one of these will be finally applied to the display and why ...

captain_a
  • 3,328
  • 1
  • 14
  • 23
  • by the meaning of "CSS", style="x" over style in html over css file. But some rules will apply first by the detail degree of that rule, or the !important properpty. – xfx Dec 11 '13 at 06:50

1 Answers1

4

inline-styles in a document have the highest priority, so for example say if you want to change the color of a div element to blue, but you've an inline style with a color property set to red.

<div style="font-size: 18px; color: red;">
   Hello World, How Can I Change The Color To Blue?
</div>

div {
   color: blue; 
   /* This Won't Work, As Inline Styles Have Color Red And As 
      Inline Styles Have Highest Priority, We Cannot Over Ride 
      The Color Using An Element Selector */
}

if you want to apply external css definition then here is a link

use !important, note, !important is important here, else it won't over ride the inline styles..

Note: Using !important ONLY will work here, but I've used div[style] selector to specifically select div having style attribute

Here Is a full details about all you want.

Java Curious ღ
  • 3,622
  • 8
  • 39
  • 63