W3 CSS Validation | Value error for gradients - css

While using the W3 CSS validator i get this error
Value Error : background linear-gradient(top,#fefefe,#dddddd) is not a
background-color value : linear-gradient(top,#fefefe,#dddddd)
for this line:
background: linear-gradient(top, #fefefe, #dddddd);
as well as:
background: -webkit-linear-gradient(top, #fefefe, #dddddd);
and other lines when I try to use gradient.
The gradients works, but am I using the wrong syntax?

CSS3 has not been finalized yet, meaning the validator is likely not validating against the latest working draft of CSS3. Also, the validator will probably not validate vendor specific css like -moz-* or -webkit-*
see the most recent draft from w3 for the specification on using linear gradients.
BTW, I believe "top" in your code should be "to top" as the direction of the gradient. Example 12 from the draft:
Below are various ways of specifying a basic vertical gradient:
linear-gradient(yellow, blue);
linear-gradient(to bottom, yellow, blue);
linear-gradient(180deg, yellow, blue);
linear-gradient(to top, blue, yellow);
linear-gradient(to bottom, yellow 0%, blue 100%);

What version of CSS are you choosing on the validator? Is it set to CSS3? I've known the validator to throw weird errors when in fact there was nothing wrong with my code.

Try the following generator:
http://www.colorzilla.com/gradient-editor/
This will give you the correct syntax for all browsers.

The w3c's validator uses the recommendations of the w3c. linear-gradient has not become a recommendation from the w3c, and therefore it is not technically "valid". The other browser vendors have went ahead and implemented what is specified in the working draft (hoping that it won't change much from now until when the w3c finalizes the specification). This is why you need the vendor prefixes for it to work.

As long as gradients are not part of a final specification, the w3c validator will throw an error for this. don't rely on the validator for "experimental" features in draft state.
so, you're fine with your syntax, but beware of different implementations in browsers.

Value Error : width Parse Error - 90px)
width: calc(100% - 90px); width: -moz-calc(100% - 90px); width: -webkit-calc(100% - 90px);

Related

CSS design in old IE browsers [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
Why does the background and the menu buttons shape not display correctly in IE versions < 11? The page looks ok in Chrome, IE 11, etc.
http://www.kine-stammheim.ch/
It's possible that you're using CSS3 properties, those properties not have support in all versions of the browsers and in some cases need for special prefixers.
Check this link http://www.w3schools.com/cssref/css3_browsersupport.asp
For example your background made with css has this prefixes:
-webkit-linear-gradient
-moz-linear-gradient
-ms-linear-gradient
-o-linear-gradient
Review this here -webkit-linear-gradient(
here is your background definition for #main:
background: -moz-linear-gradient(center top , #DBDBDB, #FFFFFF) repeat scroll 0 0 rgba(0, 0, 0, 0);
IE don't understand the -moz prefix
you need the complete definition in order to support the other browser families, e.g.:
background: rgb(69,72,77);
background: -moz-linear-gradient(top, rgba(69,72,77,1) 0%, rgba(0,0,0,1) 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(69,72,77,1)), color-stop(100%,rgba(0,0,0,1)));
background: -webkit-linear-gradient(top, rgba(69,72,77,1) 0%,rgba(0,0,0,1) 100%);
background: -o-linear-gradient(top, rgba(69,72,77,1) 0%,rgba(0,0,0,1) 100%);
background: -ms-linear-gradient(top, rgba(69,72,77,1) 0%,rgba(0,0,0,1) 100%);
background: linear-gradient(to bottom, rgba(69,72,77,1) 0%,rgba(0,0,0,1) 100%);
Look at: https://www.google.de/search?q=vendor+specific+CSS+extensions
Websites breaking in one type but working in another is usually related to illegal usage of HTML or CSS. Some browser allow you to do something you're not really allowed to do meanwhile others don't.
Use the w3.org HTML validation service to find errors on your website (HTML), you can take look at your results here, you'll see that you got some errors on your website.
You can also use the w3.org CSS validation service to find errors on your website (CSS), you can take a look at your results here.
You will see that your website has over 100 errors in the CSS; this is probably the cause of your problem. Fix your HTML and CSS and your website should render just fine.
Also check available tables to see which CSS and HTML attributes work on all browsers, some don't, yet.
You could use the Mozilla Developer Network to check the compatibility of browsers. Let's, for example check the -moz- attribute you're using in your CSS;
Browser Lowest version Support of
Internet Explorer --- ---
Firefox (Gecko) 1.0 (1.0) -moz-appearance Not fully supported
Opera (Presto) --- ---
Safari | Chrome | WebKit 3.0 | 1.0 | 522 -webkit-appearance
You'll see that you'll have problems on certain browsers, like Internet Explorer.
You can also check the table here.
Note that compatibility issues are mainly related to HTML5 and CSS3, which are the newest versions.

CSS Future Proof Linear Gradient

I've got the following piece of code online:
background-image: -webkit-linear-gradient(left, rgba(0,0,0,0), rgba(0,0,0,0.75), rgba(0,0,0,0));
background-image: -moz-linear-gradient(left, rgba(0,0,0,0), rgba(0,0,0,0.75), rgba(0,0,0,0));
background-image: -ms-linear-gradient(left, rgba(0,0,0,0), rgba(0,0,0,0.75), rgba(0,0,0,0));
background-image: -o-linear-gradient(left, rgba(0,0,0,0), rgba(0,0,0,0.75), rgba(0,0,0,0));
Which works fine.
Now I'm no CSS-expert but I notice that all of those are prefixed. Is it wise to add a prefix-less version as well? What would it be?
Is it wise to add a prefix-less version as well?
Yes, you should always provide the un-prefixed version of any prefixed CSS code you use.
What would it be?
In the case of gradients, the version you have is the same as the standard; just drop the prefix.
But note that there was also an earlier variant of the webkit syntax for gradients, which you may also want to specify if you want to support older webkit browsers.
You should also include a plain colour background as a fallback for unsupported browsers.
If you're in any doubt about these things, consult sites like CanIUse or MDN.
If you want to get really cross-browser compatible, you may also note the IE9 and earlier do not support CSS gradients at all (with or without prefix). The plain colour fallback will work, but if you want a gradient there are alternative solutions (my preferred option is generally CSS3Pie, but there are pure CSS options if you prefer; they're not nice though).
The unprefixed, W3C standard, name is linear-gradient.
I am always using the Ultimate CSS Gradient Generator. It works just perfectly.
Your example would result in:
background: linear-gradient(to left, rgba(0,0,0,0) 0%,rgba(0,0,0,0.75) 50%,rgba(0,0,0,0) 100%);
To future proof the linear gradient just add at the end of your existing code this:
background-image: linear-gradient(left, rgba(0,0,0,0), rgba(0,0,0,0.75), rgba(0,0,0,0));
Like this when the browsers drop the prefix it will still be able to use the generic code.

css3 and dreamweaver

i have just downloaded dreamweaver cs5.5 and am trying to apply css3 to my page, however although my current css is working fine both in dreamweaver and other coders the new css3 is not being applied.
eg i am trying to apply border-radius, although it is showing up in my css list as i type it out (unlike microsoft expression 4, which is'nt although i believe it should), it is not being applied to the actual page.
i have also tried using box-shadow, and linear-gradient, both unsuccessfully which made me believe that it is a css3 issue.
could it be something like setting up dreamweaver to accept css3, (ticking/unticking something in settings).
i am a beginner, any help would be appreciated and also i have looked it up before submitting q, but it seems not much info on css3 and especially css3 with dreamweaver.
thanks in advance
Did you make sure to include properties for all browsers? also, can we see your css?
Cross compatible linear gradient needs to look like this:
linear-gradient(bottom, rgb(48,54,48) 0%, rgb(54,61,54) 100%);
-o-linear-gradient(bottom, rgb(48,54,48) 0%, rgb(54,61,54) 100%); /*opera*/
-moz-linear-gradient(bottom, rgb(48,54,48) 0%, rgb(54,61,54) 100%);/*mozilla*/
-webkit-linear-gradient(bottom, rgb(48,54,48) 0%, rgb(54,61,54) 100%);/*chrome*/
-ms-linear-gradient(bottom, rgb(48,54,48) 0%, rgb(54,61,54) 100%);/*IE*/
Please see what browser you are using Internet explorer 8 and below may not support the css3 newly introduced styles.check it in a browser like chrome. Also refer to the answer from #rfinz you can see how he does it for different browsers. You probably have to work along the same lines

CSS Properties Extension

I am a web developer, I recently looked at GMAIL's new LOGIN PAGE preview and there is a Sign In button, I was really excited about its UI. I did some surgery of Page's CSS and found some properties like:
**background-color: #4D90FE;
background-image: -webkit-gradient(linear,left top,left bottom,from(#4d90fe),to(#4787ed));
background-image: -webkit-linear-gradient(top,#4d90fe,#4787ed);
background-image: -moz-linear-gradient(top,#4d90fe,#4787ed);
background-image: -ms-linear-gradient(top,#4d90fe,#4787ed);
background-image: -o-linear-gradient(top,#4d90fe,#4787ed);
background-image: linear-gradient(top,#4d90fe,#4787ed);**
Now can anyone please tell me how can I maximize the page's optimization for all popular browsers using these kind of CSS extension properties. I mean is there any reference link for these extensions or some other good stuff.
Thanks.
You should use google to find such information, a lot of it has been around since early 2010.
but here are some examples of browser specific gradient codes:
.gradient-bg {
/* fallback/image non-cover color */
background-color: #1a82f7;
/* fallback image */
background-image: url(images/fallback-gradient.png);
/* Safari 4+, Chrome 1-9 */
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#2F2727), to(#1a82f7));
/* Safari 5.1+, Mobile Safari, Chrome 10+ */
background-image: -webkit-linear-gradient(top, #2F2727, #1a82f7);
/* Firefox 3.6+ */
background-image: -moz-linear-gradient(top, #2F2727, #1a82f7);
/* Opera 11.10+ */
background-image: -o-linear-gradient(top, #2F2727, #1a82f7);
}
Taken from here.
To find out which browser supports which selector has a lot to with testing.
If you just need cross-browser-gradients, use http://www.colorzilla.com/gradient-editor/ (supports also IE6-9).
To find out, which technique is supported by which browser http://caniuse.com is a good resource.
There is a pretty comprehensive list of Mozilla's CSS extensions (or simply things that haven't been fully standardized yet) here: https://developer.mozilla.org/en/CSS_Reference/Mozilla_Extensions
There is also an attempt to list all vendor-specific CSS properties under http://webdesign.about.com/od/css/a/css-extensions.htm but it is probably pretty incomplete and outdated - this area changes fast. In the end, you should better look at CSS3. Either a feature is already listed there which means that vendor prefixes will likely be dropped soon - or it is not and then using this feature in a production webpage isn't recommendable (its meaning might change significantly or browsers might stop supporting it altogether).
This is a list that I keep on me all times as a point of reference.
I hope this is of some use to you
http://qooxdoo.org/documentation/general/webkit_css_styles

CSS background gradient validation

I've got a number of CSS styles in my site's stylesheet that use the following, or variations of:
background: -webkit-gradient(
linear,
left bottom,
left top,
color-stop(0.0, #585858),
color-stop(1.0, #ACACAC)
);
background: -moz-linear-gradient(
center bottom,
#585858 0%,
#ACACAC 100%
);
My problem is that when it comes to validating the CSS using the W3C Validator, I get the following error:
Value Error : background -webkit-gradient(linear,left bottom,left top,color-stop(0.0,#585858),color-stop(1.0,#acacac)) is not a background value : -webkit-gradient(linear,left bottom,left top,color-stop(0.0,#585858),color-stop(1.0,#acacac)) -webkit-gradient(linear,left bottom,left top,color-stop(0.0,#585858),color-stop(1.0,#acacac))
As far as I'm aware, the CSS is fine...is this a problem with the validator I should make the testing team I work with aware of?
You are using vendor specific experimental implementations of CSS properties. They aren't valid CSS.
One of the options for the validator will allow you to downgrade vendor extensions from errors to warnings in the reports (so if you are choosing to use them on a production site you can find any errors that aren't related to using non-standard extensions).

Resources