?
Solved

Overruling shortcuts, how to set specificity to overrule ALL?

Posted on 2008-10-06
4
Medium Priority
?
359 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
Mr_Splash earned 140 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

When writing CSS, there are a few simple rules that will make your life easier.    1. Using ‘* {box-sizing:border-box;}’. Using this will wrap all your elements in a nice little compact box-model that will give you the width you want, like so... …
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

719 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