FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

How to make a style (Class/Id) important

 


imagefree
How can i define a style so that the browsers prefers the style properties over those that come after it.


For Example:

here is a style
#name or
.name
(
-----------------------;
-----------------------;
}
a { -------; }

the name class/id is applied to <a> tag. Although a is defined later, so it should overrule the name class/id, but i want the name class/id to still effect the <a> tag.

(Remember! i cant edit the second style definition ie, definition of <a> tag.)
I dont know how to specify my requirements, if you got the point, please help me, otherwise please ask more info.

Thanks
rvec
in the style sheet the order of arguments doesn't really matter. If you want to use some properties for more than one class or id try this:

Code:
#id, .class, a {
    properties
}


This will make the properties affect #id, .class and a
imagefree
rvec wrote:
in the style sheet the order of arguments doesn't really matter. If you want to use some properties for more than one class or id try this:

Code:
#id, .class, a {
    properties
}


This will make the properties affect #id, .class and a



no i want to use 2 properties for 1 element/tag, so that if there is a conflict between the both two ( in case the same thing is defined twice differently), i will specify which should overrule.

Thanks
rvec
i don't think that's possible. It's called Cascading Style Sheet, if you change those rules it's not really Cascading any more.
sonam
I am not sure what are your think but class is strongest then id or blank definition. In that case if you create some class and define a tag with this class then you will get result from class definition not from a definition. It is not important what is before and what is letter. From a definition created link will get only something what is not defined in class (in my example this is text-decoration).

CSS:
Code:
<style type="text/css">
<!--
.something {
background-color : #ffcc00;
font-size : 20px;
 }
a {
font-size : 10px;
background-color : #990000;
text-decoration: none;
}
-->
</style>


HTML:
Code:
<a class="something" href="index.php">LINK</a>
<br />
<a href="index.php" >LINK</a>


Sonam
SamiTheBerber
You can add some style to be most important by adding !important on that style.

For example:
Code:
a {
    color: red !important;
}
a.class1 {
    color: blue;
}
The color in use should be red.
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.