2013-06-05 6:09, Marty wrote:
> On Wed, 05 Jun 2013 08:37:59 +0700, JJ wrote:
[...]
>> I can see a /zero-width space/ Unicode character after the end of
>> ":hover" rule blocks. You can't simply use keyboard to generate that
>> special character so, it's unlikely that you've made a mistake.
Actually, it is possible to enter the character from the keyboard, but
that does not normally happen.
> The original code I found online and pasted it into
> my css file.
Copy and paste causes all kinds of trouble. The problem might have been
in the fragment you copied.
> By mistake, do [you] mean it is unlikely there is anything wrong with my code
> and there is a hidden character I can't see in it?
The U+200B ZERO WIDTH SPACE character (ZWSP) *is* an error in your code.
It is hidden in the sense that it is zero-width, so you do not normally
see it, but in CSS code, it sits there like any other character and gets
parsed, or rather makes the CSS parser go wild.
> Then why does it work
> each time a flip them around?
If the order is changed so that the ZWSP is moved to the end of the
style sheet, it cannot really harm anyone.
> I guess I should ask if you have a clue as to why this does not work.
I must admit that the theoretical side of the matter is somewhat
obscure. The code has a ZWSP after a rule, after the "}" that terminates
the rule that starts with a.blue:hover. There is a ZWSP at the very end
of the style sheet, too. For some reason, the CSS Validator
http://jigsaw.w3.org/css-validator/ issues an error message, and a
cryptic one ("Parse Error [ ]"), about the first occurrence only.
Wait... let's start the CSS code with
@charset "utf-8";
Then we get:
17 a.blue:hover Lexical error at line 11, column 2. Encountered:
"\u200b" (8203), after : "" } a.red { display:block ; width:120px ;
height:120px ; background:url("redpicture.gif") no-repeat ; }
22 a.red:hover Lexical error at line 22, column 2. Encountered:
"\u200b" (8203), after : "" }
This makes much more sense.
Anyway, you need to delete those ZWSP's. How you do that depends on the
editor you are using. Personally, I would use BabelPad, which lets me
see information about all the invisible characters, too.
On the other hand, the code you have copied is crap. To mention some bad
things about it, it uses px dimensions; it sets background without
setting background color and text color; it uses clueless class names
"blue" and "red"; it makes a gif image get replaced by a jpeg image on
mouseover; it has incorrect HTML syntax (values of the width attribute);
it has <a> elements (which you call "link tags") with no content; it has
crappy CSS coding style which uses spaces where none is needed, before
";", and does not use spaces after ":" where they should be used for
readability.
So the code is best thrown away. Write your own code when you have
learned HTML and CSS sufficiently.
--
Yucca,
http://www.cs.tut.fi/~jkorpela/