Jump to main navigation


Posts Tagged ‘Opera’

Styling table captions with CSS: fixing the width problem

Styling table captions with CSS is not always an easy task. The specific issue I'll be dealing with in this article is the fact that the width of the caption doesn't naturally fit the width of the table. First I'll introduce the problem and then present a cross browser solution. Read the full text...

Applying CSS to Opera only

[Edit: 080828] This hack targets only Opera 9 and below, but fails in (at least) v9.52. You should not use it unless you're specifically targeting Opera 9 and below.

If you ever need to apply certain styles to Opera only, there is an easy way that I found in Jeff Starr's post, 'CSS Hack Dumpster'. All you need to do is prefix your selector with html:first-child.

For example, let's see how you would add a left margin of 10px to all paragraphs in all browsers except Opera:

p {
  margin-left: 10px;
}

html:first-child p {
  margin-left: 0;
}

This hacks validates and seems reasonably safe. As always, it's a risk to use hacks in your CSS (what would happen if, say, Internet Explorer 12 matched html:first-child? Any websites using this hack wouldn't work correctly in IE12). I'm still going to use it though, it seems quite safe to me.

Additional content and navigation

Categories

Recent comments