Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Having a problem with CSS validation


  • Please log in to reply
12 replies to this topic

#1 Wolfy87

Wolfy87

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:07:04 PM

Posted 18 March 2009 - 01:54 PM

Well, the title pritty much says it all, my html validates fine but when i do my CSS it throughs 4 errors:
22 img.fade Parse Error opacity=50)
23 img.fade Property -moz-opacity doesn't exist : 0.5
28 img.unfade Parse Error opacity=100)
29 img.unfade Property -moz-opacity doesn't exist : 1.0

And here is my code, have i got somthing wrong?
p
{
font-family:verdana;
color:white;
font-size:17px;
}

a
{
font-family:verdana;
font-size:17px;
}

img
{
vertical-align: bottom;
border: 0;
}

img.fade
{
filter:alpha(opacity=50);
-moz-opacity:0.5;
}

img.unfade
{
filter:alpha(opacity=100);
-moz-opacity:1.0;
}

Thanks, Wolfy87.

BC AdBot (Login to Remove)

 


#2 burn1337

burn1337

  • Banned
  • 311 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:11:04 AM

Posted 19 March 2009 - 01:31 AM

Well it has been awhile since I have done any filters for images but... Try "opacity:0.5; filter: alpha(opacity=50);"

#3 nixx

nixx

  • Members
  • 159 posts
  • OFFLINE
  •  
  • Local time:03:04 AM

Posted 23 March 2009 - 04:38 AM

filter:alpha(opacity=50) isn't valid. I think it's some sort of hack.

You could use opacity:0.5 instead but it's only valid in CSS3 and I don't think it'd work in IE (or at least older versions of it)

#4 nixx

nixx

  • Members
  • 159 posts
  • OFFLINE
  •  
  • Local time:03:04 AM

Posted 23 March 2009 - 04:40 AM

Here's a workaround for getting a valid css.

http://blog.evaria.com/2007/validate-css-style-opacity/

It basically inserts the statement via javascript.

#5 Wolfy87

Wolfy87
  • Topic Starter

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:07:04 PM

Posted 23 March 2009 - 02:52 PM

Ok, the opacity:0.5; works fine on firefox and filter: alpha(opacity=50); works fine on IE, although it dose not validate i suppose it will have to do, my main thing i want to validate is my html and thats fine at the moment.

Thanks for the help guys, Wolfy87.

#6 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:01:04 PM

Posted 23 March 2009 - 05:31 PM

It basically inserts the statement via javascript.

That does not make the javascript valid. It just hides it from the validator, and will only work if trying to validate a static copy. If one tries to validate a live copy, it would still fail.

#7 KamakaZ

KamakaZ

  • Members
  • 739 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Victoria
  • Local time:06:04 AM

Posted 24 March 2009 - 12:02 AM

Sorry, but what is the benifits of having "validated" code, other than the obvious, it conforms to the standards and will therfore work with all browsers?

I do strive to make a website that has code that will be viewable on most browsers, but why bother if it is just one small issue? As long as it is displayed on browsers correctly i would be happy, even if it didn't validate.

There's no place like 127.0.0.1
There are 10 types of people in the world, those that can read binary, and those who can't.


#8 burn1337

burn1337

  • Banned
  • 311 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:11:04 AM

Posted 24 March 2009 - 02:46 AM

On the contrary KamakaZ, just because the code is validated, and conforms to the "standards" does not at all mean that it will work with all browsers... Internet Explorer is not W3C compliant, so even if CSS2 is validated through W3C, that does not mean it will work with Internet Explorer users... The only good thing really with being W3C compliant and validated is that it proves a point to employers and potential clients that he does know how to code... Microsoft refuses to be W3C compliant, they barely agreed to be somewhat compliant with some CSS2 standards in Internet Explorer 8.

#9 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:01:04 PM

Posted 24 March 2009 - 06:17 AM

Microsoft refuses to be W3C compliant, they barely agreed to be somewhat compliant with some CSS2 standards in Internet Explorer 8.

Actually, they ended up being less standardized because developers complained that too many web pages broke (which is why there is a quirks mode). This move towards strictness started with IE7. There is a nice article about it on the developer's blog. And I would argue that the true standard is that there are no standards. If there were, pages would not render in any browser without correct code.

Sorry, but what is the benifits of having "validated" code, other than the obvious, it conforms to the standards and will therfore work with all browsers?

Because otherwise every time a browser updates it's parsing engine, pages are guaranteed to break. While there is no guarantee that the pages will render the same across all browsers, the pages are guaranteed to render as they were written.

EDIT: This part needs a clarification. Properly written code will always validate properly, and will always run. For too long, browsers have allowed code from sloppy developers to work; they try to guess the intent of the code. For example, Firefox will (sometimes) parse improperly nested tags, or improperly closed tags. IE will almost never do that. What if one day Firefox decides to change their quirks mode so that improperly nested tags do not render properly? Then all of those those developers who didn't take the time and care to write proper code will have pages that do not render.

just because the code is validated, and conforms to the "standards" does not at all mean that it will work with all browsers.

That is not true. Code that adheres to standards will render exactly as it is written. The difference is appearance comes from the way each browser's parse engine handles the code. It is no different than using two different compilers to build an executable. If the code is correct, it will compile every time, although it might not look the same.
There are tons of articles that have been discussing IE8's interoperability issues for months previous to the release of IE8.

#10 KamakaZ

KamakaZ

  • Members
  • 739 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Victoria
  • Local time:06:04 AM

Posted 24 March 2009 - 06:53 PM

fair enough. makes a fair bit of sense.

There's no place like 127.0.0.1
There are 10 types of people in the world, those that can read binary, and those who can't.


#11 nixx

nixx

  • Members
  • 159 posts
  • OFFLINE
  •  
  • Local time:03:04 AM

Posted 24 March 2009 - 09:19 PM

It basically inserts the statement via javascript.

That does not make the javascript valid. It just hides it from the validator, and will only work if trying to validate a static copy. If one tries to validate a live copy, it would still fail.


hmm you're right, didn't think of that one. So, got any ideas on a possible workaround for opacity? If you do, please share :D

#12 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:01:04 PM

Posted 25 March 2009 - 09:28 AM

You would use style="opacity:0.4;filter:alpha(opacity=40)", just like you stated, but it will not validate at this point because it is not a standard yet, but it is in the CSS recoomendation. Code that doesn't validate because it is not properly formed or has syntax errors is not the same as code that will not validate because the recommendations have not yet caught up with the real world. In this case, it is acceptable to not have the code validate.

#13 Wolfy87

Wolfy87
  • Topic Starter

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:07:04 PM

Posted 25 March 2009 - 06:23 PM

Ok thanks groovicus, how long till they bring in the new css then and should i start coding in html5 because i saw it on w3c but its not in use yet. I code in notepad so if they are changin to 5 and some of the things i use are going to become decipricated then i might as well start now.

Thanks, Wolfy87.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users