tags:

views:

54

answers:

4

This works:

a { color: hsla(0,100%,50%,0.2) }

And this does not:

img { color: hsla(0,100%,50%,0.2) }

Is there something like img { opacity: 1 } that allows to define hsl values to an image?

+5  A: 

text and images are 2 different things.

text is rendered by the browser with the settings you provide (decoration, size font color ...)

an image is rendered in another way. the browser does not have information about what is on the image, and can therefor not alter the image itself.

parameters like color etc will not have effect on the image.

btw: the color parameter defines the text color

@ edit: If you want to apply a "color" to an image, you could create a div with a background image, and then in that div another div with a background color and an opacity. that way the transparant color will be overlayed on the image.

you can see some examples here.

(is that what you are looking for ?)

Nealv
Are you implying that "img { opacity: 1 }" is not applied to the alpha channel of the image?
kalyanji
@kalyanji I don't think he is implying that. He is saying that the `color` attribute has no meaning on an image element.
Pekka
no alpha(opacity) is something else, but if you would apply a color (eg. red) to an image, what would be the point, the image would be a red square@Pekka: exactly
Nealv
Thanks Nealv for the link. For a noob like me, this is amazing.
kalyanji
A: 

The color attribute is used as the drawing colour for text characters, borders and such. It does not apply to bitmap images.

Therefore, it doesn't matter whether you add alpha channel information to your colour value or not: The whole of the declaration doesn't apply.

opacity is different, because it specifies the alpha value for the whole element.

Pekka
A: 

The only way to impact the colors of an image with css is to use opacity to control the alpha channel. Note that you could make a hack to (sort of) change the luminance of your image by placing another element on top of if. Ensure that it covers the image exactly by adjusting position and size, make the background-color black, and set the opacity to 0.5.

grddev
A: 

You can apply filters to images in some browsers: Firefox allows you to apply SVG filters to HTML content from CSS, but Chrome, Safari and Opera you'll need to wrap your content in SVG to apply filters to them, here's an example that works in Opera. There might not be an appropriate SVG filter for what you need, but it may be an avenue worth exploring if you have no other alternatives.

In Internet Explorer you might be able to use a static filter.

robertc
The alternative I used was based on sprites in an image, then adjust the tag's `background-position` attribute for `hover` and `active` states or whenever the color model if the image should change. Now I'm looking for a way to avoid manually creating sprites.
kalyanji