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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CSS Validation for noob

Status
Not open for further replies.

Floodster

Technical User
Jan 28, 2005
204
Guys,
I have validated all my XHTML (with some help from this forum) & now I'm trying to validate my CSS. I have read other posts here that say that your CSS is okay even if you get warnings but I would like to try & correct these warnings if possible as I think they contribute to some display issues in Firefox. I have not published my site yet so I am going to have to include my code in this post.
Code:
/* 1st menu mouse off */
.m0l0iout {
	font-family: Georgia, "Times New Roman", Times, serif;
	font-size: 12px;
	text-decoration: none;
	padding: 4px 4px;
	color: #336699;
	border : 2px solid #336699;
	background: #dcdcdc;
}
/* 1st menu mouse off */
.m0l0oout {
	text-decoration : none;
}
/* 1st menu mouse on */
.m0l0iover {
	font-family: Georgia, "Times New Roman", Times, serif;
	font-size: 12px;
	text-decoration : none;
	padding: 4px 4px;
	color: #000000;
	border : 2px solid #336699;
	background: #6699FF;
}
/* 2nd menu mouse off */
.m0l1iout {
	font-family: Georgia, "Times New Roman", Times, serif;
	font-size: 12px;
	text-decoration: none;
	color: #FFFFFF;
	padding: 4px 4px;
	border : 1px solid #000000;
	background: #336699;
}
/* 2nd menu mouse off*/
.m0l1oout {
	text-decoration : none;
}
/* 2nd menu mouse on */
.m0l1iover {
	font-family: Georgia, "Times New Roman", Times, serif;
	font-size: 12px;
	text-decoration : none;
	padding: 4px 4px;
	color: #000000;
	border : 1px solid #000000;
	background: #6699FF;
}

input {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	color: #336699;

}
form {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	color: #336699;
	padding-right: 5px;
	padding-left: 5px;

}
p {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	color: #000000;
	padding-right: 5px;
	padding-left: 5px;
	padding-top: 0px;
	padding-bottom: 0px;
	list-style-type: none;
	white-space: normal;


}
h2 {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 22px;
	font-weight: bold;
	color: #336699;
	text-align: center;
	text-decoration: underline;

}h5 {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	font-weight: bold;
	color: #336699;
	padding: 0px 5px;

}

table {
	border: thin solid #b1c0d5;
	padding-right: 5px;
	padding-left: 5px;
	background-color: #FFFFFF;
	margin: 0px 5px;
	padding-top: 0px;
	padding-bottom: 0px;

}
h4 {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 10px;
	font-weight: bold;
	color: #336699;
	padding-right: 1px;
	padding-left: 5px;
}
h3 {
	font-family: Arial, Helvetica, sans-serif;
	color: #FF0000;
	font-size: 14px;
	padding-right: 5px;
	padding-left: 5px;



}
select {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	color: #336699;
}
h1 {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 36px;
	font-weight: bold;
	color: #FF0000;
	padding-right: 5px;
	padding-left: 5px;
}
/* Nifty Corners */
.rtop,.artop{display:block}
.rtop *,.artop *{display:block;height:1px;overflow:hidden;font-size:1px}
.artop *{border-style: solid;border-width:0 1px}
.r1,.rl1,.re1,.rel1{margin-left:5px}
.r1,.rr1,.re1,.rer1{margin-right:5px}
.r2,.rl2,.re2,.rel2,.ra1,.ral1{margin-left:3px}
.r2,.rr2,.re2,.rer2,.ra1,.rar1{margin-right:3px}
.r3,.rl3,.re3,.rel3,.ra2,.ral2,.rs1,.rsl1,.res1,.resl1{margin-left:2px}
.r3,.rr3,.re3,.rer3,.ra2,.rar2,.rs1,.rsr1,.res1,.resr1{margin-right:2px}
.r4,.rl4,.rs2,.rsl2,.re4,.rel4,.ra3,.ral3,.ras1,.rasl1,.res2,.resl2{margin-left:1px}
.r4,.rr4,.rs2,.rsr2,.re4,.rer4,.ra3,.rar3,.ras1,.rasr1,.res2,.resr2{margin-right:1px}
.rx1,.rxl1{border-left-width:5px}
.rx1,.rxr1{border-right-width:5px}
.rx2,.rxl2{border-left-width:3px}
.rx2,.rxr2{border-right-width:3px}
.re2,.rel2,.ra1,.ral1,.rx3,.rxl3,.rxs1,.rxsl1{border-left-width:2px}
.re2,.rer2,.ra1,.rar1,.rx3,.rxr3,.rxs1,.rxsr1{border-right-width:2px}
.rxl1,.rxl2,.rxl3,.rxl4,.rxsl1,.rxsl2,.ral1,.ral2,.ral3,.ral4,.rasl1,.rasl2{border-right-width:0}
.rxr1,.rxr2,.rxr3,.rxr4,.rxsr1,.rxsr2,.rar1,.rar2,.rar3,.rar4,.rasr1,.rasr2{border-left-width:0}
.r4,.rl4,.rr4,.re4,.rel4,.rer4,.ra4,.rar4,.ral4,.rx4,.rxl4,.rxr4{height:2px}
.rer1,.rel1,.re1,.res1,.resl1,.resr1{border-width:1px 0 0;height:0px !important;height /**/:1px}
div#nifty{
	margin: 0;
	background:#D4DDFF;
}
div#container {
	float: none;
	height: 450px;
	width: 700px;
	margin-top: 110px;
	margin-right: 0px;
	margin-bottom: 0px;
	margin-left: 170px;
	overflow: auto;


}
div#banner {
	height: 61px;
	width: 400px;
	margin-top: -50px;
	margin-right: 0px;
	margin-bottom: 0px;
	margin-left: 180px;
	
	
}
div#banner_nifty{
	margin: 0;
	background:#b1c0d5;
}
div#sidebar_nifty{
	margin: 0;
	background:#CDFFAA;
	background-color: #CDFFAA;
	width: 10px;
}
.table2 {
	background-color: #FFFFFF;
	border: none;

}
.table3 {
	background-color: #B4CEF7;
	border: none;
}
div#menubar_nifty{
	margin: 0;
	background:#B4CEF7;
	background-color: #B4CEF7;

}
div#privacy_nifty{
	margin: 0;
	background:#CCCCCC;
	
	}
div#privacy a{
	font-family: Arial, Helvetica, sans-serif;
	font-size: 10px;
	background-color: #CCCCCC;
	padding: 1px 5px 1px 5px;
	color: #000000;
	text-decoration: none;
	font-weight: bold;

}

a:link {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	color: #990033;
	font-weight: normal;
	
}
a:visited {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	color: #336699;
}
a:hover {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	color: #990033;
	text-decoration: underline;
	font-weight: normal;
}
.imgw3c{
	border: none;
}

Thanks.
 
I'm not entirely sure what you are asking us for. You've used the validator, you know what warnings there are... are there any specific ones you don't know how to fix?

If not, what are you asking? If so, perhaps you can give us the details?

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Ok,
What I'm asking for is do I have to fix the warnings or can I leave them & if I do have to fix them how do I fix them??
I have included the details from the validator;
Code:
W3C CSS Validator Results for file://localhost/H:\Research\Projects\Website\css\menu.css
To work as intended, your CSS style sheet needs a correct document parse tree. This means you should use valid HTML.

Warnings
URI : file://localhost/H:\Research\Projects\Website\css\menu.css
Line : 58 (Level : 1) You have no background-color with your color : input 
Line : 58 (Level : 1) Same colors for color and background-color in two contexts .m0l1iout and input 
Line : 64 (Level : 1) You have no background-color with your color : form 
Line : 64 (Level : 1) Same colors for color and background-color in two contexts .m0l1iout and form 
Line : 72 (Level : 1) You have no background-color with your color : p 
Line : 86 (Level : 1) You have no background-color with your color : h2 
Line : 86 (Level : 1) Same colors for color and background-color in two contexts .m0l1iout and h2 
Line : 94 (Level : 1) You have no background-color with your color : h5 
Line : 94 (Level : 1) Same colors for color and background-color in two contexts .m0l1iout and h5 
Line : 103 (Level : 1) You have no color with your background-color : table 
Line : 113 (Level : 1) Same colors for color and background-color in two contexts .m0l1iout and h4 
Line : 113 (Level : 1) You have no background-color with your color : h4 
Line : 119 (Level : 1) You have no background-color with your color : h3 
Line : 130 (Level : 1) You have no background-color with your color : select 
Line : 130 (Level : 1) Same colors for color and background-color in two contexts .m0l1iout and select 
Line : 136 (Level : 1) You have no background-color with your color : h1 
Line : 161 (Level : 2) Redefinition of height : .rer1 
Line : 161 (Level : 2) Redefinition of height : .res1 
Line : 161 (Level : 2) Redefinition of height : .rel1 
Line : 161 (Level : 2) Redefinition of height : .resr1 
Line : 161 (Level : 2) Redefinition of height : .re1 
Line : 161 (Level : 2) Redefinition of height : .resl1 
Line : 164 (Level : 1) You have no color with your background-color : div#nifty 
Line : 190 (Level : 1) You have no color with your background-color : div#banner_nifty 
Line : 195 (Level : 1) You have no color with your background-color : div#sidebar_nifty 
Line : 195 (Level : 2) Redefinition of background-color : div#sidebar_nifty 
Line : 199 (Level : 1) You have no color with your background-color : .table2 
Line : 204 (Level : 1) You have no color with your background-color : .table3 
Line : 210 (Level : 1) You have no color with your background-color : div#menubar_nifty 
Line : 210 (Level : 2) Redefinition of background-color : div#menubar_nifty 
Line : 215 (Level : 1) You have no color with your background-color : div#privacy_nifty 
Line : 232 (Level : 1) You have no background-color with your color : a:link 
Line : 239 (Level : 1) Same colors for color and background-color in two contexts .m0l1iout and a:visited 
Line : 239 (Level : 1) You have no background-color with your color : a:visited 
Line : 244 (Level : 1) You have no background-color with your color : a:hover 
Valid CSS information
.m0l0iout {
font-family : Georgia, "Times New Roman", Times, serif; 
font-size : 12px; 
text-decoration : none; 
padding : 4px; 
color : #336699; 
border : 2px solid #336699; 
background : #dcdcdc; 
} 
.m0l0oout {
text-decoration : none; 
} 
.m0l0iover {
font-family : Georgia, "Times New Roman", Times, serif; 
font-size : 12px; 
text-decoration : none; 
padding : 4px; 
color : #000000; 
border : 2px solid #336699; 
background : #6699ff; 
} 
.m0l1iout {
font-family : Georgia, "Times New Roman", Times, serif; 
font-size : 12px; 
text-decoration : none; 
color : #ffffff; 
padding : 4px; 
border : 1px solid #000000; 
background : #336699; 
} 
.m0l1oout {
text-decoration : none; 
} 
.m0l1iover {
font-family : Georgia, "Times New Roman", Times, serif; 
font-size : 12px; 
text-decoration : none; 
padding : 4px; 
color : #000000; 
border : 1px solid #000000; 
background : #6699ff; 
} 
input {
font-family : Arial, Helvetica, sans-serif; 
font-size : 12px; 
color : #336699; 
} 
form {
font-family : Arial, Helvetica, sans-serif; 
font-size : 12px; 
color : #336699; 
padding-right : 5px; 
padding-left : 5px; 
} 
p {
font-family : Arial, Helvetica, sans-serif; 
font-size : 12px; 
color : #000000; 
padding-right : 5px; 
padding-left : 5px; 
padding-top : 0; 
padding-bottom : 0; 
list-style-type : none; 
white-space : normal; 
} 
h2 {
font-family : Arial, Helvetica, sans-serif; 
font-size : 22px; 
font-weight : bold; 
color : #336699; 
text-align : center; 
text-decoration : underline; 
} 
h5 {
font-family : Arial, Helvetica, sans-serif; 
font-size : 12px; 
font-weight : bold; 
color : #336699; 
padding : 0 5px; 
} 
table {
border : thin solid #b1c0d5; 
padding-right : 5px; 
padding-left : 5px; 
background-color : #ffffff; 
margin : 0 5px; 
padding-top : 0; 
padding-bottom : 0; 
} 
h4 {
font-family : Arial, Helvetica, sans-serif; 
font-size : 10px; 
font-weight : bold; 
color : #336699; 
padding-right : 1px; 
padding-left : 5px; 
} 
h3 {
font-family : Arial, Helvetica, sans-serif; 
color : #ff0000; 
font-size : 14px; 
padding-right : 5px; 
padding-left : 5px; 
} 
select {
font-family : Arial, Helvetica, sans-serif; 
font-size : 12px; 
color : #336699; 
} 
h1 {
font-family : Arial, Helvetica, sans-serif; 
font-size : 36px; 
font-weight : bold; 
color : #ff0000; 
padding-right : 5px; 
padding-left : 5px; 
} 
.rtop, .artop {
display : block; 
} 
.rtop *, .artop * {
display : block; 
height : 1px; 
overflow : hidden; 
font-size : 1px; 
} 
.artop * {
border-style : solid; 
border-width : 0 1px; 
} 
.r1, .rl1, .re1, .rel1 {
margin-left : 5px; 
} 
.r1, .rr1, .re1, .rer1 {
margin-right : 5px; 
} 
.r2, .rl2, .re2, .rel2, .ra1, .ral1 {
margin-left : 3px; 
} 
.r2, .rr2, .re2, .rer2, .ra1, .rar1 {
margin-right : 3px; 
} 
.r3, .rl3, .re3, .rel3, .ra2, .ral2, .rs1, .rsl1, .res1, .resl1 {
margin-left : 2px; 
} 
.r3, .rr3, .re3, .rer3, .ra2, .rar2, .rs1, .rsr1, .res1, .resr1 {
margin-right : 2px; 
} 
.r4, .rl4, .rs2, .rsl2, .re4, .rel4, .ra3, .ral3, .ras1, .rasl1, .res2, .resl2 {
margin-left : 1px; 
} 
.r4, .rr4, .rs2, .rsr2, .re4, .rer4, .ra3, .rar3, .ras1, .rasr1, .res2, .resr2 {
margin-right : 1px; 
} 
.rx1, .rxl1 {
border-left-width : 5px; 
} 
.rx1, .rxr1 {
border-right-width : 5px; 
} 
.rx2, .rxl2 {
border-left-width : 3px; 
} 
.rx2, .rxr2 {
border-right-width : 3px; 
} 
.re2, .rel2, .ra1, .ral1, .rx3, .rxl3, .rxs1, .rxsl1 {
border-left-width : 2px; 
} 
.re2, .rer2, .ra1, .rar1, .rx3, .rxr3, .rxs1, .rxsr1 {
border-right-width : 2px; 
} 
.rxl1, .rxl2, .rxl3, .rxl4, .rxsl1, .rxsl2, .ral1, .ral2, .ral3, .ral4, .rasl1, .rasl2 {
border-right-width : 0; 
} 
.rxr1, .rxr2, .rxr3, .rxr4, .rxsr1, .rxsr2, .rar1, .rar2, .rar3, .rar4, .rasr1, .rasr2 {
border-left-width : 0; 
} 
.r4, .rl4, .rr4, .re4, .rel4, .rer4, .ra4, .rar4, .ral4, .rx4, .rxl4, .rxr4 {
height : 2px; 
} 
.rer1, .rel1, .re1, .res1, .resl1, .resr1 {
border-width : 1px 0 0; 
height : 0 !important; 
height : 1px; 
} 
div#nifty {
margin : 0; 
background : #d4ddff; 
} 
div#container {
float : none; 
height : 450px; 
width : 700px; 
margin-top : 110px; 
margin-right : 0; 
margin-bottom : 0; 
margin-left : 170px; 
overflow : auto; 
} 
div#banner {
height : 61px; 
width : 400px; 
margin-top : -50px; 
margin-right : 0; 
margin-bottom : 0; 
margin-left : 180px; 
} 
div#banner_nifty {
margin : 0; 
background : #b1c0d5; 
} 
div#sidebar_nifty {
margin : 0; 
background : #cdffaa; 
background-color : #cdffaa; 
width : 10px; 
} 
.table2 {
background-color : #ffffff; 
border : none; 
} 
.table3 {
background-color : #b4cef7; 
border : none; 
} 
div#menubar_nifty {
margin : 0; 
background : #b4cef7; 
background-color : #b4cef7; 
} 
div#privacy_nifty {
margin : 0; 
background : #cccccc; 
} 
div#privacy a {
font-family : Arial, Helvetica, sans-serif; 
font-size : 10px; 
background-color : #cccccc; 
padding : 1px 5px; 
color : #000000; 
text-decoration : none; 
font-weight : bold; 
} 
a:link {
font-family : Arial, Helvetica, sans-serif; 
font-size : 12px; 
color : #990033; 
font-weight : normal; 
} 
a:visited {
font-family : Arial, Helvetica, sans-serif; 
font-size : 12px; 
color : #336699; 
} 
a:hover {
font-family : Arial, Helvetica, sans-serif; 
font-size : 12px; 
color : #990033; 
text-decoration : underline; 
font-weight : normal; 
} 
.imgw3c {
border : none; 
}
 
By leaving them will it create problems with other browsers (I currently test in IE)??

How would I go about correcting them if it will create problems.

Thanks.
 
But to answer yor question - "How would I fix...", the answer is pretty much given to you in the mesasages:

Line : 113 (Level : 1) You have no background-color with your color : h4

So, simply add in the background-color declaration.

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Warnings are just that, warnings.

The reason you get the background colour warning can be explained thus:

Imagine you had a div with white text in it. You put a graphic in the background of the div and the graphic is dark enough so that you can see the text.
What happens if hte image doesn't load or images are turned off in the user's browser?
If you specify a dark background colour then even if the image isn't there, the user could still see the text.

The rule of thumb is if you specify a colour then you should specify a contrasting background colour too.




<honk>*:O)</honk>
Foamcow Heavy Industries - Web site design in Cheltenham and Gloucester
Ham and Jam - British & Commonwealth forces mod for Half Life 2
 
I wonder if you good people could give me some more advice.
I am using CSS for my styles but I am still using DIV & position absolute to determine where each layer goes. Is this OK to do or should I be using CSS to does this as well.
If I've not explained myself very well I have pasted some code to explain.
Code:
<div id="main" style="position:absolute; width:700px; height:450px; z-index:; left: 180px; top: 100px; overflow: auto; z-index: 0;">
 <div id="nifty">
this is where you can edit

  </div>
</div>

thanks
 
That is css you're using to position that div. But since you ask, I would use absolute positioning only when absolutely necessary, at all other times I would revert to normal document flow.
 
Absolute positioning is fine to use if you understand all of the pitfalls associated with it... it's generally not used for most documents unless absolutely necessary (for example, for positioning rounded corner graphics, logos, etc etc)... It's rarely used wholesale for blocks of text (although there's nothing to stop you doing this - but again, as long as you are aware of the pitfalls of doing so).

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top