TeamPhotoshop
Reviews, updates and in depth guides to your favourite mobile games - AppGamer.com
Forum Home Latest Posts Search Help Subscribe

A short css question

Page: 1 Reply
Aug 28th 2005#170031 Report
Member since: Jun 3rd 2003
Posts: 1867
Is it considered legitamite to have div's in the html file that have an id referring to an external CSS file, but with no content inside them? For example:

< div id="image" > < /div >


(and in the CSS file)

#image {
background-image: url(bg.gif);
}




(just ignore the spaces in the div tags... otherwise the forum will pick it up)


Is this legitamite CSS coding? I heard somewhere, (maybe I'm mistaken), that not putting content inside the
is technically not legitamite coding. Just wondering though.
Reply with Quote Reply
Aug 28th 2005#170033 Report
Member since: Mar 18th 2001
Posts: 6632
Put a non-breaking space in there. Or better yet, the caption for the image, and then just set it to visibility: hidden.
Reply with Quote Reply
Aug 29th 2005#170034 Report
Member since: Jun 3rd 2003
Posts: 1867
thanks derek.

by non-breaking space, do you mean   ? if so, then that's kind of what I've been doing, though I thought there might be a better way than having a highlight-able space out in the middle of nowhere for no reason.

As for captions, I use this generally for background design purposes and the like, so i'm guessing there's no captions to these images, but if i were to make one up, for example "topleft" would that mean this?


[html]
< div id="topleft" > topleft < /div >

[css file]

#topleft {
visibility: hidden;
}



If I do that, then any background image I set in the div also is hidden and now it's no good to me anymore.

though, I can do this:

[html]
< div id="topleft" >
< div id="topleftcontent" > Caption text here
< /div >
< /div >

[css]

#topleft {
background-image: url(bg.gif);
}

#topleftcontent {
visibility: hidden;
}





This second method works nicely. Is it legitamite? If so, then that's definitely a good way to go. No highlight-able spaces or nothin'.
Reply with Quote Reply
Aug 29th 2005#170035 Report
Member since: Mar 18th 2001
Posts: 6632
You don't need captions for decorations.

Don't nest divs like that. Instead do this:

< div id="topleft">< p>& nbsp;< /p>< /div>


#topleft p {
visibility: hidden;
}

That means that rule will apply to any P tag contained in a tag with the topleft ID.
Reply with Quote Reply
Aug 29th 2005#170043 Report
Member since: Jun 3rd 2003
Posts: 1867
Coolio, worked nicely. Thanks a lot deke.


One more quick question. Is it never legitamite css coding to nest div tags?
Reply with Quote Reply
Aug 29th 2005#170049 Report
Member since: Mar 18th 2001
Posts: 6632
You want to use nested divs as little as possible, and classes/ids as little as possible. Much better to do like I showed you above, where you just make rules based on the structure of the HTML document. More flexible, and just better.
Reply with Quote Reply
Aug 30th 2005#170054 Report
Member since: Jun 3rd 2003
Posts: 1867
haha, you're killing me man xD what's wrong with using classes and ids.... unfortunately I rape that stuff..l. seriously, I dont use anything but divs with IDs to do layouts. lol I feel pretty guilty about my coding now lol
Reply with Quote Reply
Aug 30th 2005#170056 Report
Member since: Mar 18th 2001
Posts: 6632
Yeah they call it "Class-itis". Try to do it without having classes and **** everywhere. It's a lot of wasteful code.
Reply with Quote Reply
Aug 30th 2005#170071 Report
Member since: May 1st 2002
Posts: 3034
its just annoying to do it without derek :P it would be easy if it wasn't for ****ing internet explorer which can't read code for ****.
Reply with Quote Reply
Sep 3rd 2005#170165 Report
Member since: Jun 3rd 2003
Posts: 1867
the bastards.
Reply with Quote Reply
Page: 1 Back to top
Please login or register above to post in this forum