Solved

Overruling shortcuts, how to set specificity to overrule ALL?

Posted on 2008-10-06
4
338 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

CSS3 Custom checkboxes This article shows how to style the checkbox form element using only CSS. Works in: Chrome, FF, Safari, Opera, IE9+ Uses modernizr.js to check for :checked pseudo class, falling back to plain old checkboxes (IE8 and bel…
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
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 Micro Tutorial viewers will learn how to create a CSS image sprite (In a later tutorial, viewers will learn how to use CSS and HTML to create a navigation menu using this sprite) Open a new Photoshop document with a width of (Icon width)x(N…

758 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

21 Experts available now in Live!

Get 1:1 Help Now