rgba used without transparency

For technical support for all editions of CSS HTML Validator. Includes bug reports.
Post Reply
User avatar
RSteinwand
Rank VI - Professional
Rank VI - Professional
Posts: 551
Joined: Mon Jun 09, 2008 2:12 pm
Location: Fargo, ND
Contact:

rgba used without transparency

Post by RSteinwand » Tue May 03, 2016 10:48 am

Hi Albert,

I wonder if this is worth flagging:

Code: Select all

background:-webkit-gradient(linear,left top,left bottom,color-stop(0%,rgba(246,142,124,1)),color-stop(36%,rgba(244,72,41,1)),color-stop(100%,rgba(244,72,41,1)))
Rgba is used, but the transparency is set to 1, which means that rgb could be used.

What I'd REALLY like to see tho would be a "Fix it" button. That would be a nice feature for the Professional version. :D
Rick

User avatar
Albert Wiersch
Site Admin
Site Admin
Posts: 3222
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: rgba used without transparency

Post by Albert Wiersch » Tue May 03, 2016 11:20 am

Hi Rick,

That sounds like a good idea for some type of "tip" or "suggestion" message. I'll see what I can do.

Yes, "fix it" features would be great but there are practicality issues with it so I don't think it would be wise to go in that direction right now.
Image
Albert Wiersch

User avatar
RSteinwand
Rank VI - Professional
Rank VI - Professional
Posts: 551
Joined: Mon Jun 09, 2008 2:12 pm
Location: Fargo, ND
Contact:

Re: rgba used without transparency

Post by RSteinwand » Tue May 03, 2016 11:56 am

I suspect for compatibility and physical size, using "#" instead of "rgb" would be best if transparency isn't needed.

Thanks Albert.
Rick

User avatar
RSteinwand
Rank VI - Professional
Rank VI - Professional
Posts: 551
Joined: Mon Jun 09, 2008 2:12 pm
Location: Fargo, ND
Contact:

Re: rgba used without transparency

Post by RSteinwand » Wed May 04, 2016 6:20 pm

I would hate to start coding "fix-it" buttons all over the place. What a tremendous task that would take.
Rick

User avatar
Albert Wiersch
Site Admin
Site Admin
Posts: 3222
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: rgba used without transparency

Post by Albert Wiersch » Wed Jun 01, 2016 5:16 pm

Hi Rick,

Looks like this made it into the next update so it will make it into v16!

When a color like this is used:
rgba(246,142,124,1)

A "Good Style" message like this should be displayed:
The rgba() color value has an alpha channel value of 1 (fully opaque). When the alpha value is 1 and transparency is not needed, it is recommended that rgb(246,142,124) or #F68E7C be used instead for smaller file size and improved compatibility and readability. This message is displayed up to 3 times.

However, it won't generate this for -webkit-gradient() (used in your example) because CSE HTML Validator does not check this function's syntax. It looks like -webkit-gradient() is for some fairly old/obsolete browsers.
Image
Albert Wiersch

User avatar
RSteinwand
Rank VI - Professional
Rank VI - Professional
Posts: 551
Joined: Mon Jun 09, 2008 2:12 pm
Location: Fargo, ND
Contact:

Re: rgba used without transparency

Post by RSteinwand » Wed Jun 01, 2016 5:28 pm

Hi Albert, correct. I use -webkit-gradient for my html-to-pdf conversion, WkHtmlToPdf, which is still based on an older version of WebKit QT. If I want gradients in my pdf's, I need to use it.

Nice that you provide the hex color equivalent. That'll be sweet.

Thanks.
Rick

User avatar
Albert Wiersch
Site Admin
Site Admin
Posts: 3222
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: rgba used without transparency

Post by Albert Wiersch » Thu Jun 02, 2016 8:20 am

RSteinwand wrote:Hi Albert, correct. I use -webkit-gradient for my html-to-pdf conversion, WkHtmlToPdf, which is still based on an older version of WebKit QT. If I want gradients in my pdf's, I need to use it.
I see. That makes sense. :)
RSteinwand wrote:Nice that you provide the hex color equivalent. That'll be sweet.
I did some work on some color messages to display/include alternative equivalent color notations. I also added support for #RGBA and #RRGGBBAA formats (new CSS4 color notations). These aren't well supported yet but if you use them then you should get a warning containing suggestions with equivalent colors using the more widely supported color notations - like rgba().
Image
Albert Wiersch

User avatar
RSteinwand
Rank VI - Professional
Rank VI - Professional
Posts: 551
Joined: Mon Jun 09, 2008 2:12 pm
Location: Fargo, ND
Contact:

Re: rgba used without transparency

Post by RSteinwand » Thu Jun 02, 2016 9:56 am

Are you proving the the 3 digit hex equivalent, when it applies? Like #334455 To #345? :D
Rick

User avatar
Albert Wiersch
Site Admin
Site Admin
Posts: 3222
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: rgba used without transparency

Post by Albert Wiersch » Thu Jun 02, 2016 10:22 am

RSteinwand wrote:Are you proving the the 3 digit hex equivalent, when it applies? Like #334455 To #345? :D
In some lists of suggestions for alternative color notations, yes! But if #RRGGBB is used when #RGB could be used, there is no message/tip about using #RGB instead... I wonder if that would be useful... hmmmmm. What are your thoughts on that?
Image
Albert Wiersch

User avatar
RSteinwand
Rank VI - Professional
Rank VI - Professional
Posts: 551
Joined: Mon Jun 09, 2008 2:12 pm
Location: Fargo, ND
Contact:

Re: rgba used without transparency

Post by RSteinwand » Thu Jun 02, 2016 11:30 am

Probably more work than it's worth. I was just mentioning it because you had thought of so much stuff I was hoping to think of something you hadn't.

You could go so far into this project that you suggest using "gray" instead of #808080 because it's 3 less characters or "red" instead of #f00 because it's one less character. There are web sites that'll minimize your css for you, if you want to get that picky.
Rick

User avatar
Albert Wiersch
Site Admin
Site Admin
Posts: 3222
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: rgba used without transparency

Post by Albert Wiersch » Thu Jun 02, 2016 12:00 pm

Yes, best to use a minimizer if one wants to get picky. I wasn't only thinking of the space savings though. Some people might like the "style" of #RGB better... perhaps because they find it easier to read, more efficient, or something of the like.

But like you said, probably not worth doing. CSE HTML Validator already generates a lot of messages and I'm concerned about message overload. Of course most of these tip/advice messages can be disabled but I wonder how many people do that.

Anyway, I'll file the thought in the back of my head. :D
Image
Albert Wiersch

User avatar
RSteinwand
Rank VI - Professional
Rank VI - Professional
Posts: 551
Joined: Mon Jun 09, 2008 2:12 pm
Location: Fargo, ND
Contact:

Re: rgba used without transparency

Post by RSteinwand » Thu Jun 02, 2016 12:05 pm

File it waaay back. :D
Rick

Post Reply