...

View Full Version : CSS Validation Fail



hmvrulz
02-25-2009, 02:30 AM
When i try to validate CSS on

http://harshamv.com

http://jigsaw.w3.org/css-validator/validator?profile=css21&warning=0&uri=http%3A%2F%2Fharshamv.com%2F

am getting errors


58 #rightnav Property opacity doesn't exist in CSS level 2.1 but exists in [css3] : 0.25
59 #rightnav Property -moz-opacity doesn't exist : 0.25
60 #rightnav Parse Error opacity=25)

rangana
02-25-2009, 02:46 AM
Opacity is a CSS3 property, and the validator validates under CSS2.1.

You might want to resort on using JS instead:


<script type="text/javascript">
window.addEventListener?window.addEventListener('load',opacity,false):
window.attachEvent('onload',opacity); // FF : IE

function opacity() {
var el = document.getElementById('rightnav'); // rightnav div
el.style.opacity = 0.25;
el.style.filter = 'alpha(opacity=25)'; // IE
}
</script>


You might also find this thread useful:
http://www.codingforums.com/showthread.php?t=121004

hmvrulz
02-25-2009, 07:44 AM
Opacity is a CSS3 property, and the validator validates under CSS2.1.

You might want to resort on using JS instead:


<script type="text/javascript">
window.addEventListener?window.addEventListener('load',opacity,false):
window.attachEvent('onload',opacity); // FF : IE

function opacity() {
var el = document.getElementById('rightnav'); // rightnav div
el.style.opacity = 0.25;
el.style.filter = 'alpha(opacity=25)'; // IE
}
</script>


You might also find this thread useful:
http://www.codingforums.com/showthread.php?t=121004

Thanx. is it advisable to use Js instead of the browser specific css propertites ?

rangana
02-25-2009, 07:58 AM
JS should be used only to enhance the page, and shouldn't cripple your page when users have JS disabled.

Opactiy, will only validate if you click on the "More Options" link and choose CSS3 for the Profile.

Hope that helps.

hmvrulz
02-25-2009, 02:37 PM
Opacity is a CSS3 property, and the validator validates under CSS2.1.

You might want to resort on using JS instead:


<script type="text/javascript">
window.addEventListener?window.addEventListener('load',opacity,false):
window.attachEvent('onload',opacity); // FF : IE

function opacity() {
var el = document.getElementById('rightnav'); // rightnav div
el.style.opacity = 0.25;
el.style.filter = 'alpha(opacity=25)'; // IE
}
</script>


You might also find this thread useful:
http://www.codingforums.com/showthread.php?t=121004


should this go in to the head or body for better results ?

rangana
02-25-2009, 02:38 PM
Place it on the head.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum