The “Be Mean to Opera” Hack

This hack can be used to hide CSS from Opera (versions 5 and below):

html>body .myDiv { m\yProperty: myval; }

IE5/win and Opera 3-5 suffer from the same CSS parsing bug that is exploited in Tantek’s Box Model Hack. (Without Tantek’s hack, real-world CSS development would be much harder.) The Tantek hack has a “Be Nice to Opera” rule that allows developers to filter out Opera and simply target their CSS to correct IE5/win’s broken box model. To specifically target Opera, though, developers need to modify the “Be Nice to Opera” rule using the Simplified Box Model Hack. For example, using the following CSS, only Opera 3-5 will display the div.myDiv using red text.

div.myDiv {<br />
&nbsp;&nbsp;&nbsp;&nbsp;color: black;<br />
}<br />
html&gt;body div.myDiv {<br />
&nbsp;&nbsp;&nbsp;&nbsp;color: red;<br />
&nbsp;&nbsp;&nbsp;&nbsp;c\olor: black; /* be ~mean~ to Opera -- http://www.albin.net/css/be_mean_to_opera */<br />
}

What the heck does that mean? The “Be Mean to Opera” selector means: “select the div.myDiv descendent of the body element if the body element is a child of the html element.” Since the body element is always a child of the html element, this rule can be modified to match anything inside the body element.

IE/win (versions 6 and below) don’t support CSS2’s child selector and, thus, will ignore the entire html&gt;body rule. Opera (versions 5 and before) will ignore the property that has an escape (\) character in it. Any letter G-Z can be escaped with a backslash (\) without affecting it’s meaning. In other words, ‘\g’ will be read by a non-buggy CSS parser as ‘g’. Don’t escape the letters A-F; they are interpreted as hexidecimal numbers when escaped (‘\f’ means ‘15’ in hexidecimal). Opera 6, IE5/Mac, IE6/win, Netscape 6, and Mozilla all have CSS parsers that interpret escaped characters correctly; all but IE6/win (because of it’s lack of support for CSS2’s child selector) will read the html&gt;body { c\olor: black; } property.

John's picture
Filed under:
mixmagtmb's picture

Great work. Thank you!

Great work. Thank you!

Kathryn H Rybicki's picture

Could you please explain me

Could you please explain me the meaning of 'CVS'

Anonymous's picture

Nice, very nice

subject

Lisa M Torres's picture

Guys, what is CVS?

Guys, what is CVS?

Laurie K Monteiro's picture

Very good! Here is my

Maik Beken's picture

wkeves@googlemail.com

The comma-separated values (or CSV; also known as a comma-separated list or comma-separated variables) file format is a file type that stores tabular data. The format dates back to the early days of business computing. For this reason, CSV files are common on all computer platforms.
en.wikipedia.org/wiki/Comma-separated_values

Gartman6's picture

QJByelGtGAP

Welcome friends! , sexy brazilian ass, [url="http://brazilian-ass.weebly.com/"]sexy brazilian ass[/url], http://brazilian-ass.weebly.com/ sexy brazilian ass, hot women thong sex naked beach, [url="http://forums.vogue.com.au/member.php?u=84514"]hot women thong sex naked beach[/url], http://forums.vogue.com.au/member.php?u=84514 hot women thong sex naked beach, squirting girls, [url="http://forums.vogue.com.au/member.php?u=84519"]squirting girls[/url], http://forums.vogue.com.au/member.php?u=84519 squirting girls,

Multiblock's picture

The “Be Mean to Opera” Hack

very usefull thing!
but what is CSV?

Matthi's picture

CSV

CSV files you can open with openoffice...

wow gold's picture

Is it formally known as the

Is it formally known as the "Be Nice to Opera Rule"? Talk about patronising.

Eve Isk

anthem blue cross california's picture

re: be nice to opera

Thanks, John. Nice to know that some people are actually considering Opera. Surprised me.

wow gold's picture

wow gold

We supply WoW Gold for wow players, you can Buy Wow Gold,wow power leveling,and world of warcraft gold server here, Cheap WoW Gold always waiting for you!

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <code> <del> <ins> <blockquote> <q> <sub> <sup> <ul> <ol> <li> <dl> <dt> <dd>
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Lines and paragraphs break automatically.

More information about formatting options