Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help to tidy up my CSS

Status
Not open for further replies.

audiopro

Programmer
Apr 1, 2004
3,165
GB
I am having a problem with keeping my CSS code tidy.
The tutorials deal with individual elements but I have yet to find one which explains how to bolt it all together.
I have the code below which works ok but I am sure it can be tidied up a lot.

Code:
.adbox1 {
position:relative;
    width:180px;
	font-size:12px;
	color: #000080;
	font-family:Verdana,sans-serif;
	font-weight:normal;
	text-decoration:none;
	text-align:center;
	display:block;
}
.adbox1 h3{
position:relative;
    width:180px;
	font-size:14px;
	color: #800000;
	font-family:Verdana,sans-serif;
	font-weight:bold;
	text-decoration:none;
	text-align:center;
	display:block;
}

.adbox1 h4{
position:relative;
    width:180px;
	font-size:10px;
	color: #000080;
	font-family:Verdana,sans-serif;
	font-weight:normal;
	text-decoration:none;
	text-align:center;
	display:block;
}
I am sure that I have seen examples something like
Code:
.adbox1 {
position:relative;
    width:180px;
	font-size:12px;
	color: #000080;
	font-family:Verdana,sans-serif;
	font-weight:normal;
	text-decoration:none;
	text-align:center;
	display:block;
[red]h3{color:#fff000};[/red]
}
but I cannot get it to work.


Keith
 
I don't get it. And it is hard to suggest without seeing the rest of the code. Mostly wihtout the html. But here's something you could do:
Code:
.adbox1, .adbox1 h3, .adbox1 h4 {
    position: relative;
    width: 180px;
    font-size: 12px;
    color: #000080;
    font-family: Verdana,sans-serif;
    font-weight: normal;
    text-align: center;
}
.adbox1 h3 {
    font-size: 14px;
    color: #800000;
    font-weight: bold;
}

.adbox1 h4 {
    font-size: 10px;
}
I am not even sure if you need all that, but that's something.
 
The question really is can the three seperate declarations, for the elements be combined into 1 statement as in my second example above.
I have been experimenting with CSS and I am still getting to grips with it and want to write the code as efficiently as possible.

Keith
 
I don't understand your question. No, your syntax is invalid. You cannot define different styles (like color and size) into the same group and expect the browser to understand. Yes, there are better ways to code your css based on inheritance but without you showing us your html, we can't really help much.
 
It would appear that you did understand the question.
Code:
You cannot define different styles (like color and size) into the same group
That is the answer to it.
Thankyou

Keith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top