Jump to content

CSS syntax question


williamrouse

Recommended Posts

I was reading an article and trying to duplicate the contents of a CSS file which contained code about a translucent link for menu items when I came across these definitions in a CSS file. The syntax of the div before the class statements confuse me and I don?t understand what this means. Does this mean that for any div in a class named content or links the following rule applies? Thanks!

div #content {
   background: transparent url(../images/halfscr-blue.gif) 0 0 repeat scroll;
   voice-family: "\"}\"";
   voice-family: inherit;
   background: #468 url(../images/shell-blue.jpg) 0 0 no-repeat fixed;
}

div#links a {
   background: transparent url(../images/halfscr-black.gif) 0 0 repeat scroll;
/*  voice-family: "\"}\"";
   voice-family: inherit; */
   background: transparent url(../images/shell-fade.jpg) 0 0 no-repeat fixed;
}

Link to comment
Share on other sites

It's actually nothing to do with voice-family, or at least not using it for that purpose, it's a hack to use a browser bug for a different purpose.

 

IE browsers 5.0 and 5.5 use the first image, the .gif, but browsers which parse correctly will overwrite the .gif with the .jpg image because they ignore the \ and } in specific places when used with the voice-family attribute and apply the second image while IE5.0 and IE5.5 stop at the special \ and }.

 

See http://www.ericmeyeroncss.com/bonus/trick-hide.html and

http://tantek.com/CSS/Examples/boxmodelhack.html and

http://archivist.incutio.com/viewlist/css-discuss/37121

which explain the hack when used in different circumstances.

 

I don't think it's used much now, people prefer to use a conditional comment.

Edited by Wickham
Link to comment
Share on other sites

But what is the deal with the "div#links a"?

Why is it not just "#links a" and then the div in the HTML referring to class "links"?

WBR

 

it's just more specific. For example, "div#links a" refers only to "a" elements inside a div with an id of "links".

 

 

whereas just "#links a" could refer to any "a" element within an element with an id of "links":

 

link

Link to comment
Share on other sites

whereas just "#links a" could refer to any "a" element within an element with an id of "links":

 

link

But considering that an ID is supposed to be used only once on any given page, that kind of seems redundant - not wrong, but overkill. Or not? However, for a class, it makes perfect sense to me.
Link to comment
Share on other sites

But considering that an ID is supposed to be used only once on any given page, that kind of seems redundant - not wrong, but overkill. Or not? However, for a class, it makes perfect sense to me.

 

I would usually agree that it is overkill. However, since the stylesheet uses usually links to all the pages on the site, it would allow the coder to use the #links id in different ways. Sure, it can't be used more than once on the page, but it could be assigned to a different element per page. (In my opinion, that doesn't make sense -- I'd prefer to keep my use of ids consistent, but it is an option.)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...