Is there any syntax to eliminate the ambiguity in CSS class names between two stylesheets?

Let's say I have an HTML page that imports two stylesheets, for example:

<link href="Styles1.css" rel="stylesheet" type="text/css" />
<link href="Styles2.css" rel="stylesheet" type="text/css" />

Also suppose that a class with the same name appears in both of these stylesheets.

.SomeStyle {font-weight:bold;  } /* in Styles1.css */
.SomeStyle {font-weight:normal;} /* in Styles2.css */

Question : Is there a syntax in which I can apply the class to an element in a way that eliminates the version of the style to use?

For example (pseudo code):

<span id="mySpan" class="Styles1.css:SomeStyle">Example</span>

Disclaimer: I know that the best solution would be to resolve the name conflict between the two stylesheets, but I ask mainly academic reasons.

+5
source share
4 answers

, , , ?

. . .

, , :

.SomeStyle.First {font-weight:bold;  } /* in Styles1.css */
.SomeStyle.Second {font-weight:normal;} /* in Styles2.css */

<span id="mySpan" class="SomeStyle Second">Example</span>
+7

, , .

<body class="newer">

.SomeStyle {font-weight:bold;} /* in Styles1.css */
.newer .SomeStyle {font-weight:normal;} /* in Styles2.css */

. , . , :

.SomeStyle {font-weight:bold;} /* in Styles1.css */
.SomeStyle {font-weight:normal;} /* in Styles2.css */
.SomeStyle {font-weight:bold;} /* in PageSpecific.css */
+1

, jQuery - ( ) , . , , jQuery, , , , ?

jQuery , - , . , 2- , , , ...

...

0

Just a thought, not very detailed, but. Perhaps you can use php include and have a submit button to call the function via JavaScript to include the required css in it. (you really won't need JS)

0
source

All Articles