CSS complications
I just learned enough CSS last week to fix a specific problem. I needed my menu text links to be one color and my main section text to be a different color. I was quite proud that I accomplished my goal... ... or did I? Everything looks as I intended when being viewed in IE5, with orange text links (hovering yellow) over the green menu background, with white 'non-link' text.
But then I checked it out in Netscape 6 and my menu has reverted back to the color scheme that should be used only in the main secion: black text and blue links.
And then I checked it out in Netscape 4 and I almost blew chunks. What in the world happened here? Aqua text and Lime green links? Where did these colors even come from?
Here's the link to see it, and the code, for yourself:
charlottemlb.com/softball/test3.shtml
Anyone got ideas or advice? I realize that satisfying every possible browser is a pipe dream, but is there anyway to make the menu color scheme work in all the major browsers (IE 5+ and NS 4+)? (aside from using graphics)
Busy posted this at 03:06 — 26th February 2002.
He has: 6,151 posts
Joined: May 2001
the a:hover doest work on NS4.x but the font coloring does.
a:link {...}
a:active {...}
a:visted {...}
a:hover {...}
are for normal text links, for secondary links you need something like:
a:link.menu {...}
a:active.menu {...}
a:visted.menu {...}
a:hover.menu {...}
and in the tag you have class="menu"
also dont use quotes around RGB colors, color:#CCCCCC; is how it should be written
Suzanne posted this at 03:18 — 26th February 2002.
She has: 5,507 posts
Joined: Feb 2000
Ah, Busy beat me to it.
S
Busy posted this at 03:21 — 26th February 2002.
He has: 6,151 posts
Joined: May 2001
forgot to add using link colors in your body tag can cause different effects in older browsers if used with CSS
mairving posted this at 03:25 — 26th February 2002.
They have: 2,256 posts
Joined: Feb 2001
Well a couple of things. One if you remove the quotes "" around the rgb color value:
a.menu { color: "#ffaa00"; to a.menu { color: #ffaa00;
That should fix the NS problem. The hover color won't work in NS 4.7 but the link still works okay. I would also clean it up a little to make it easier to follow and add the a:visited, a:active and a:link tags also. I usually make them the same as my a: value. I would also consider using an external stylesheet.
Here is kind of a generic one that I use some, changing the font size and color to fit:
<?php
A { text-decoration:none;
font-weight: 900;
font-size : 10px;
color:#000099;
font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
}
A:link {text-decoration:none;
font-weight: 900;
font-size : 10px;
color:#000099;
font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
}
A:visited {text-decoration:none;
font-weight: 900;
font-size : 10px;
color:#000099;
font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
}
A:active {text-decoration:none;
font-weight: 900;
font-size : 10px;
color:#000099;
font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
}
A:hover {text-decoration:underline;
font-weight: 900;
font-size : 10px;
color:#990000;
font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
}
.nav {
text-decoration:none;
font-weight: 900;
font-size : 10px;
color:#000099;
font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
}
.nav:active {
text-decoration:none;
font-weight: 900;
font-size : 10px;
color:#000099;
font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
}
.nav:link {
text-decoration:none;
font-weight: 900;
color:#000099;
font-size: 10px;
font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
}
.nav:visited {
text-decoration:none;
font-weight: 900;
color:#000099;
font-size: 10px;
font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
}
.nav:hover {
text-decoration:none;
font-weight: 900;
color:#990000;
font-size : 10px;
font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
}
.navwhite {
text-decoration:none;
font-weight: 900;
font-size : 10px;
color:#FFFFFF;
font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
}
.navwhite:active {
text-decoration:none;
font-weight: 900;
font-size : 10px;
color:#FFFFFF;
font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
}
.navwhite:link {
text-decoration:none;
font-weight: 900;
color:#FFFFFF;
font-size: 10px;
font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
}
.navwhite:visited {
text-decoration:none;
font-weight: 900;
color:#FFFFFF;
font-size: 10px;
font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
}
.navwhite:hover {
text-decoration:underline;
font-weight: 900;
color:#FFFFFF;
font-size : 10px;
font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
}
?>
Mark Irving
I have a mind like a steel trap; it is rusty and illegal in 47 states
fifeclub posted this at 03:57 — 26th February 2002.
He has: 688 posts
Joined: Feb 2001
Thank you all. I was actually HOPING that I was doing something that was obviously wrong, thereby making it easier to find what it was I should fix. It'll be a few days before I can sit down and work on it but all the above responses looks very promising for me fixing it. (And if the hover doesn't work in some browsers than that's not major). I'm thanking you guys just about everyday lately but Thanks again!
mmi posted this at 04:02 — 26th February 2002.
They have: 457 posts
Joined: Jan 2001
hey Mike - why is everything on one line? - makes it tough to diagnose
here's mmy analysis:
1) since this is a .shtml file, you are correct in not including and tags - however, you do have a closing tag in there - probably ignored
2) Busy's right - the attributes you've set in your BODY tag are overwriting the style sheet - e.g., link="#0000ff" is making the links blue instead of orange
3) vspace and hspace are not supported as attributes for TD, but rather for IMG
Web Xpertz Community Forums for Webmasters & Developers
Where You Can Learn, Advise, and Have Fun in the Process
Suzanne posted this at 06:37 — 26th February 2002.
She has: 5,507 posts
Joined: Feb 2000
mmi -- html doesn't over-ride CSS -- only when the CSS is malformed and dysfunctional. Then the browser reverts to html.
Suzanne
mmi posted this at 07:48 — 26th February 2002.
They have: 457 posts
Joined: Jan 2001
I believe you're correct, Suzanne - in this case, mmy reasoning was "malformed and dysfunctional"
disaster-master posted this at 07:54 — 26th February 2002.
She has: 2,154 posts
Joined: May 2001
I hate to change the subject here but MMI, why do you always put mm's when you type my or me?
Just curious is all. *like a cat*
The Webmistress posted this at 09:30 — 26th February 2002.
She has: 5,586 posts
Joined: Feb 2001
and you know what curiosity did to the cat!
Stick with it Mike, it's taken me a while to get to grips with css but it's well worth it. A good tool is TopStyle from bradsoft.com and you can use the evaluation copy to check compatability, clean up your style sheet and many other useful things. Well worth checking it out.
Julia - if life was meant to be easy Michael Angelo would have painted the floor....
fifeclub posted this at 13:26 — 26th February 2002.
He has: 688 posts
Joined: Feb 2001
One quick question, I am using SSI to call a header and footer. The header encompasses everything from to the beginning of the text in the main table, including all the CSS info. Knowing this, is there still an advantage in using an exernal CSS file? I just figured that I would still have to edit only one file (the header), and my thinking was that doing it this way would cut down on the browser and server having to call extra files. Was my thinking valid? and is there an advantage of using external CSS if it's in the header SSI anyway?
mmi posted this at 15:23 — 26th February 2002.
They have: 457 posts
Joined: Jan 2001
if content being styled appears on only one page, I'm guessing there's no advantage to "externalizing" - on another point, is there any consequence to placing a TITLE in an SSI file?
DM: I need to clean mmy keyboard - sommetimmes the em sticks
Julia: I believe curiosity killed the cat - but did you know that "satisfaction brought 'im back?"
Web Xpertz Community Forums for Webmasters & Developers
Where You Can Learn, Advise, and Have Fun in the Process
fifeclub posted this at 16:21 — 26th February 2002.
He has: 688 posts
Joined: Feb 2001
mmi-
the only reason I start my header file after the title tag is because I found that some search engines put a heavy emphasis on words found in page titles. This way I can title pages individually, like "Mysite.com - sub-title."
Otherwise, back to the CSS, I would maintain the CSS from the one header file, but all my site's pages will be utilizing this file via SSI, which will in turn create the menu.
mmi posted this at 17:22 — 26th February 2002.
They have: 457 posts
Joined: Jan 2001
hey - I figured search engines was the reason - I know VERY little about this topic, but is an SSI "detected" by any of them?
fifeclub posted this at 18:56 — 26th February 2002.
He has: 688 posts
Joined: Feb 2001
Anybody can correct me if I'm wrong, but when you use SSI, it's just like breaking up parts of your web page into sections. You can theoretically have a webpage with nothing in it except all SSI calls. Then when a browser requests that page from your server, the server recognizes the .shtml extention and knows that it must first look for SSI calls and put the page together first. The end user never sees a difference. Even if you read the source code you wouldn't know (unless it's noted in a comment tag) because the SSI call will be replaced by whatever is in that external file. it's all been pre-assembled before it gets to your computer. This will also be true for search engines because once it requests your .shtml page, the server will gather up all the SSI elements and add them to produce the page before it is sent.
(If I've got part of that explaination wrong anybody can correct me )
Suzanne posted this at 23:57 — 26th February 2002.
She has: 5,507 posts
Joined: Feb 2000
No, SSI, like PHP, ASP, et cetera is server-side. The search engines pull the parsed page -- as it appears in the browser.
The only advantage to using external CSS in this case would be for validating it and developing it in the first place, or if you are using more advanced CSS and want to hide some parts from older browsers.
Of course, if you have any pages that aren't parsed, it would be helpful, but that doesn't appear to be the case.
Suzanne
Suzanne posted this at 23:58 — 26th February 2002.
She has: 5,507 posts
Joined: Feb 2000
Sorry, Mike, looks like I'm disagreeing with you -- I'm not. You have it right. But you beat me to the post!
Suzanne
mmi posted this at 06:35 — 27th February 2002.
They have: 457 posts
Joined: Jan 2001
so is there any SE-related reason to include a TITLE in an SSI? - it would appropriately be placed inside the HEAD, right? - and ya don't want multi-headed pages, do ya? :eek:
Web Xpertz Community Forums for Webmasters & Developers
Where You Can Learn, Advise, and Have Fun in the Process
Suzanne posted this at 06:44 — 27th February 2002.
She has: 5,507 posts
Joined: Feb 2000
If you have this as an include...
$variable
Or, in otherwords, if you have both SSI and a database. For some sites I've used conditional scripting in the SSI to make the titles happen -- itservices.ubc.ca for instance -- so when new pages are created, the navigation and the header include are edited, and the new page is a list of includes only.
This was to prepare for database integration in a future version of the site.
So yes -- the title is included in the header SSI so there can be unique meta tags and titles for the pages to prepare for database integration in the future.
Suzanne
mmi posted this at 07:28 — 27th February 2002.
They have: 457 posts
Joined: Jan 2001
well, I appreciate that url - but would the example you've provided be an appropriate structure for an include, i.e., with HTML and HEAD tags?
Suzanne posted this at 08:20 — 27th February 2002.
She has: 5,507 posts
Joined: Feb 2000
Anything, ANYTHING can be in an include. I could make a page thusly:
include header file
include body file
include footer file
And in the header file have to , in the body file, the content, and in the footer file
It doesn't matter to the browser because they are glued together on the server before the browser sees it.
S
fifeclub posted this at 04:01 — 28th February 2002.
He has: 688 posts
Joined: Feb 2001
So I've now implemented a combination of everybody's CSS suggestions. Thanks. From my tests it works and looks good in IE 5 and NS 6. It still has some problems in NS 4, but the glass-half-full side is that it isn't lime green and aqua anymore either. Plus I cleaned up the code to make it easier for y'all to read.
Check it out at charlottemlb.com/softball/home.shtml
Let me know if everything seems okay for the most part and I'll consider my CSS adventure to be over (for now) and I'll move back into building up the content of my site. Thanks again everyone.
P.S. The 'font size=1' tag overrides my CSS properties in the copyright at the bottom. So why do my 'font size=1' tags NOT override the CSS properties in that yellow calendar box?
Suzanne posted this at 04:52 — 28th February 2002.
She has: 5,507 posts
Joined: Feb 2000
logically there is an error in your CSS -- again, HTML does not override CSS, but if the CSS is busted, then the browser will revert to the HTML specifications.
Suzanne posted this at 04:57 — 28th February 2002.
She has: 5,507 posts
Joined: Feb 2000
Part of the problem is that you are not using well-formed HTML. Close up those paragraph tags.
Also, there is nothing specified in that area?
a:link.menu should be a.menu:link, et cetera, as well. (Check in Opera to see if it's working).
<center>
<p>
<p><font face="Helvetica, Arial" size=1 color="#000000">
© 2002 The Dugout
<br>[Beta v0.5.2]
</font>
</center>
Should be:
<p align="center">
<br>
<font face="Helvetica, Arial" size="1" color="#000000">
© 2002 The Dugout<br>[Beta v0.5.2]
</font>
</p>
Of course, it would be even better if you just turfed the font tags.
I don't see anything else glaringly wrong with the CSS, did you validate it?
Suzanne posted this at 05:45 — 28th February 2002.
She has: 5,507 posts
Joined: Feb 2000
well playing around fixing the a.class:pseudoclass thing makes the colours work in Opera, but I'm having the same problem with the bottom.
more later.
Suzanne posted this at 06:51 — 28th February 2002.
She has: 5,507 posts
Joined: Feb 2000
You have a whack of other errors in the HTML -- validating that will help considerably.
You could also set the font tag in the CSS, btw.
font {font-size: ....}
And the reason the font tag is affecting things? Two reasons: one, no valid DOCTYPE, and two, you're actually using a tag, but not declaring it in the CSS. The HTML is not overriding the CSS so much as you are setting a new state for things within the font tags. You can remove them entirely.
The inheritance is like this for that section -- Make everything what the CSS says for P, except for here, this bit, use the FONT declaration. But there is no font declaration in the CSS, so it uses the HTML instead.
If you put all the information into the CSS, it will render fine for people without CSS support (default colours and links) -- which is less than 1% of the audience for most sites. AND that way you can remove the font tags entirely.
Suzanne
fifeclub posted this at 14:53 — 28th February 2002.
He has: 688 posts
Joined: Feb 2001
Actually, the bottom copyright part is working the way I wanted to, being font size=1. It's that calendar box that I can't figure out. I realize that eventually I should change everything to CSS, and I will eventually, but it's just bugging me how the copyright section and the calendar are done the same exact way ( x ) but for some reason it works in one place and not another. But anyway, yes, I will eventually change over to inline CSS for variable text sizes.
Suzanne posted this at 19:24 — 28th February 2002.
She has: 5,507 posts
Joined: Feb 2000
Probably because of inheritance issues -- some things inherit properly, others don't.
Good luck!
Suzanne
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.