[thelist] CSS Layout questions

Burhan Khalid burhankhalid at members.evolt.org
Mon Jun 10 21:06:01 CDT 2002


> 1) What is the prevailing way of dealing with classes? Should
> I keep my character formatting stuff
> separate from my content formatting code? example:
>
> 	#banner {
> 		border:1px solid #000;
> 		border-bottom:0px;
> 		background:#cc3300;
> 		width: 100%;
> 		}
>
> is for the top of my page. I will have text in there too -
> should I continue with color: white;
> font-family etc etc in #banner or define a class for the text
> that it will contain?

The thing with classes and id's is that you can only have one instance
of an ID in a page, and many instances of a class in a page. Of course,
if you don't care about validation, just ignore the above sentence.
However, to answer your question, you can add it in there, if you think
you are only going to use it there. In other words, if you plan to use
that same style (for text) somewhere else, I'd make it a separate class.
Also, wherever possible, try and modify html tags. So, if you want to
create a bunch of text that has spacing on both sides, indented, etc.
Don't make a div. Use the <p> tag instead (afterall, you are modifying a
paragraph).


> 2) I don't understand a couple things about this workaround.
> a) when specifying #main twice, does
> the browser read the info from the first, implement it, then
> add the stuff from the second
> declaration below it? Also, what do you call it when you do
> #somename #somename { stuff }
> together?
>

The #somename #somename2 { stuff } part means "if somename2 comes after
#somename, then apply { stuff } to it". Here is an example :

Say you have a div called header.

#header { color:black; background:transparent; size:50px; etc. etc. etc.
}

If you want all p tags that are in #header to be red, then you would
write something like this :

#header p { color:red; background:transparent; }

Hopefully, this helps. I didn't get the main twice thing. Its #main
#menu (from the CSS that you put in the email). Also, a good rule to
follow is wherever you have specified color: also specify background:
(helps with validation). If you don't want to give that particular
element a background color, use background:transparent.

Hth,
Burhan

Disclaimer :

I'm not a CSS guru, so I might not be correct in my responses.
Hopefully, someone will catch them and we will both learn something.





More information about the thelist mailing list