Solved

Overruling shortcuts, how to set specificity to overrule ALL?

Posted on 2008-10-06
4
342 Views
Last Modified: 2012-05-05
I have some shortcuts I use a lot in my html pages.  Here are 2 exampleis:
.fL { float: left; }
.fR { float: right; }

The problem is that these only have specificity of 020, but I want them to overrule everything.

For example, I have a nice blockquote like this:
.contentpaneopen blockquote { float:right; }

And, because of the lower specificity, this code:
<blockquote class="fL">
gets floated right.

How can I solve this without a css sheet that would become something like this:
.fL, .contentpaneopen .fL, .otherclass .fL, #otherid .fL, #anotherid .fL, #andanotherid #insideanother .fL { float: left; }
(and so on).
0
Comment
Question by:R-U-Bn
  • 2
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
Mr_Splash earned 35 total points
ID: 22650631
The only way I can think to do this would be to give your blockquote a class that gives it the float right. i.e.

.contentpaneopen blockquote.className { float:right; }

So in your HTML all your block quotes look like
<blockquote class="className">

Then for the ones you need to float left the HTML would look like this
<blockquote class="className FL">
0
 
LVL 3

Expert Comment

by:Mr_Splash
ID: 22650675
Better yet, add this below the link to your stylesheet;

<style type="text/css">
  .fL, .contentpaneopen .fL, .otherclass .fL, #otherid .fL, #anotherid .fL, #andanotherid #insideanother .fL { float: left; }
</style>
0
 
LVL 2

Author Comment

by:R-U-Bn
ID: 22651338
Mr. Splash, your first solution is what I was thinking of as a last fall back solution.
Your second is exactly what I do not want.  With this I mean that the code you copied from me was just a bad example.  It would become full of id's and classes (actually all the ones that exist in my css).

If you don't mind, I will wait a while for possibly more solutions until I accept your first answer as a sort of confirmation that it is not possible what I want.  ( If this is rude or impolite on this site, please tell me how to ask for more opinions).

So, does any has any other opinons?
0
 
LVL 2

Author Closing Comment

by:R-U-Bn
ID: 31503441
I guess that wás the only option.  Maybe once a css protocol version will allow to SET the specificity, something like:  .fL (101) {  ..  }   :-))  (because I think there are situations where it would be usefull and efficient).
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Making my existing website "mobile friendly"... 10 41
Table changes size when I click edit 7 27
CSS Logo Problem. 2 20
CSS: How do I override in-line styling 11 14
When applying CSS to your HTML, there are many different ways to select which element(s) the CSS applies to.  Some of these selectors are more commonly known and used than others - Here are the more common ones: #X - Matches an ID of X .X - Matche…
Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now