opacity

W

windandwaves

Hi Gurus

What is the right way to set opacity in css. I use the one below, but it
gives errors in Firefox:

opacity:.50; filter: alpha(opacity=50); -moz-opacity: 0.50; margin: 0px;

TIA

Nicolaas
PS I also posted this message to the stylesheet newsgroup
 
T

Toby Inkster

windandwaves said:
opacity:.50; filter: alpha(opacity=50); -moz-opacity: 0.50; margin: 0px;

I'm not entirely sure how the margin effects opacity, but this should do
the trick:

..translucent50
{
opacity: 0.5; /* CSS 3, Moz, Safari, Konq, Opera 9 */
filter: alpha(opacity=50); /* Internet Explorer 5.5+ */
-moz-opacity: 0.5; /* Older Moz */
-khtml-opacity: 0.5; /* Older Safari, Older Konqueror */
}
 
J

Julien CROUZET

windandwaves a écrit :
Hi Gurus

What is the right way to set opacity in css. I use the one below, but it
gives errors in Firefox:

opacity:.50; filter: alpha(opacity=50); -moz-opacity: 0.50; margin: 0px;

From the CSS validator FAQ :


Why don't my scrollbar properties, filters, etc. validate?

The CSS Validator validates your style sheet against some profile, e.g.
CSS Level 1 or CSS Level 2.
Some browser Vendors however extend these profiles by new properties
like Microsoft did with the scrollbar-base-color or filter property or
Mozilla with the -moz-opacity property. The Validator is not aware of
these properties and using them makes your style sheet invalid in terms
of the CSS specifications. _Either get rid of those properties or live
with the fact, that your style sheets don't validate._ _You cannot have
both._
 
T

Toby Inkster

Julien said:
_You cannot have both._ [proprietary CSS and valid CSS]

Actually, you probably can.

There are numerous documented bugs in browser CSS parsers. By tripping the
right ones, you should be able to trick the browsers into reading some
proprietary CSS properties which are really within a CSS comment.

e.g. IE 5.x for Mac will apply this:

/* \*/ /* div{property:value;} */

though a standards-compliant browser should treat it as a comment (as
indeed all other CSS rendering engines seem to) and the CSS validator
should pass it OK.

Not that I'd recommend that in most circumstances.
 
J

Jim Higson

Toby said:
Julien said:
_You cannot have both._ [proprietary CSS and valid CSS]

Actually, you probably can.

There are numerous documented bugs in browser CSS parsers. By tripping the
right ones, you should be able to trick the browsers into reading some
proprietary CSS properties which are really within a CSS comment.

e.g. IE 5.x for Mac will apply this:

/* \*/ /* div{property:value;} */

though a standards-compliant browser should treat it as a comment (as
indeed all other CSS rendering engines seem to) and the CSS validator
should pass it OK.

Since standards compliant browsers ignore rules they doesn't understand
anyway, this seems like validation for it's own sake. And a nightmare to
maintain.
Not that I'd recommend that in most circumstances.

I agree :)
 
A

Alan J. Flavell

Since standards compliant browsers ignore rules they doesn't
understand anyway, this seems like validation for
it's own sake.
[1]

There's something in what you say. But if your documents are full of
deliberate non-standard items, you practically lose the ability to use
the validators and checkers for finding non-deliberate errors.

I got myself into just that position only yesterday, in putting ruby
annotation into what was otherwise a valid HTML/4.01 Strict document.
And did just what I'm warning about - at first I missed a real mistake
in the markup. (At least in this situation one could validate against
a custom DTD, and if I decided to go seriously into that, it's what I
would do. But for a one-off hack...)

cheers


[1] news:alt.possessive.its.has.no.apostrophe
 
J

Julien CROUZET

Après mûre réflexion, Toby Inkster a écrit :
Julien said:
_You cannot have both._ [proprietary CSS and valid CSS]

Actually, you probably can.

Actually, I think it's :

_You cannot have both._ [proprietary CSS and your sheet validates]

CSS validation, like any validation, is strict like we want it to.
 
J

Jim Higson

Alan said:
Since standards compliant browsers ignore rules they doesn't
understand anyway, this seems like validation for
it's own sake.
[1]

There's something in what you say. But if your documents are full of
deliberate non-standard items, you practically lose the ability to use
the validators and checkers for finding non-deliberate errors.

I'd only ever do this for CSS. XHTML validation is still important.
I got myself into just that position only yesterday, in putting ruby
annotation into what was otherwise a valid HTML/4.01 Strict document.
And did just what I'm warning about - at first I missed a real mistake
in the markup. (At least in this situation one could validate against
a custom DTD, and if I decided to go seriously into that, it's what I
would do. But for a one-off hack...)

For CSS, I just run it through a flex/bison parser to test the syntax. Seems
to work ok. Also, my text editor (kate) is very good at showing bad CSS
syntax.

What I like to do, btw is use server-side PHP to generate stylesheets, and
then run a little shell script to grab the output and turn it back into a
static file.

I also have a little Perl script that strips out whitespace and comments, so
I can write loads of explanations without worrying too much about inflating
the filesize.
 
W

windandwaves

Jim said:
Alan said:
Since standards compliant browsers ignore rules they doesn't
understand anyway, this seems like validation for
it's own sake.
[1]

There's something in what you say. But if your documents are full of
deliberate non-standard items, you practically lose the ability to
use the validators and checkers for finding non-deliberate errors.

I'd only ever do this for CSS. XHTML validation is still important.
I got myself into just that position only yesterday, in putting ruby
annotation into what was otherwise a valid HTML/4.01 Strict document.
And did just what I'm warning about - at first I missed a real
mistake in the markup. (At least in this situation one could
validate against a custom DTD, and if I decided to go seriously into
that, it's what I would do. But for a one-off hack...)

For CSS, I just run it through a flex/bison parser to test the
syntax. Seems to work ok. Also, my text editor (kate) is very good at
showing bad CSS syntax.

What I like to do, btw is use server-side PHP to generate
stylesheets, and then run a little shell script to grab the output
and turn it back into a static file.

what editor do you use for writing the PHP. I like to edit my css in a css
editor, but if I turn it into a PHP file I can not...
 
J

Jim Higson

windandwaves said:
what editor do you use for writing the PHP. I like to edit my css in a
css editor, but if I turn it into a PHP file I can not...

Kate, which is part of KDE.
Any standards it doesn't support with highlighting, I make my own
highlighting spec and send into the project. Not very difficult at all.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top