CSS Style Sheets?

  • Thread starter Pako
  • 20 comments
  • 952 views

Pako

Staff Emeritus
16,455
United States
NW Montana
GTP-Pako
GTP Pako
Greetings great minds of GTP (;)),

I'm working on revamping my Blue Onion site, but am having a little difficulty bypassing the "visited" properties of links. I'm not quite sure what to set the a:visited css to so that the visted properties are ignored all together. Basically I just want the a:active, a:hover, and a:link to be the only styles that change my linked text.

Any thoughts?
 
You mean you don't want the colour of the text to change once te user visits the link? In Dreamweaver you can do that by going to the Page Properties section. Then set the colour of the visited link to the same colour as the normal link.
 
Here's what I mean:
www.blueonion.net/site_test.html

You'll notice that if you go to the "Contract" button a roll the mouse off to the side, you'll see that the changing content in the upper left corner will have a link to Adobe's site. If you've never been there, it should "underline" it as you hover over the link. Go to the site, and come back to the page. Now when you hover over the link, the "Underline" is already there.

I had this problem back in the day when I first started my other site over three years ago, and finally left it be, but now I'm just requiring it to be right. :)

I want to use the style sheets and not the properies of the page. That way, even if a user has a specific settings for his colors, the css will take over, and my page will look as it was intended to.
 
Hey, thanks for trying though. I'm sure someone around here knows...

Well enough for tonight -> Off to bed.

:cheers:
 
Code:
<style type="text/css">
<!--
a:visited {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	font-style: normal;
	line-height: normal;
	font-weight: normal;
	font-variant: normal;
	text-transform: none;
	text-decoration: none;
}
-->
</style>

The most important tag is the "Text-Decoration". It needs to be set to "None" and the underline goes away when the link has already been visited by the user.

Dreamweaver users can just go to the Design menu on the side bar, click on the CSS tab and create a new a:visited style. Dreamweaver rocks!
 
Viper Zero:
Hey thanks man, I'll give that a shot tonight.... Or today if work permits. ;)

:cheers:
 
If anyone wants to see my current style sheet, you can download it here:
 

Attachments

  • styles.zip
    429 bytes · Views: 13
Pako--

I had a look at your style sheet (I couldn't open the download, so I simply viewed it through my browser... IE can't do that, but the Mac OSX-only Chimera can! :P), and I see a few issues that can be sorted out.

First off, here's what you have regarding links:
_________________________


a:active {
font-family: "Times New Roman", Times, serif;
font-size: 12pt;
font-style: normal;
font-weight: bold;
color: #FF0000;
text-decoration: none
}

a:hover {
font-family: "Times New Roman", Times, serif;
font-size: 12pt;
font-style: normal;
font-weight: bold;
color: #336699;
text-decoration: underline;
line-height: normal;
font-variant: normal;
text-transform: none
}

a:link {
font-family: "Times New Roman", Times, serif;
font-size: 12pt;
font-style: normal;]
font-weight: bold;
color: #336699;
text-decoration: none
}


______________

Before I go on, one should note that your CSS should be written in the format that I've presented above... it makes it much easier for yourself and others to read it. ;)

Now, you say that you want the "a:visted" trait to be no different than the normal "a:link" trait, right? Well, there's a very, very simple solution-- just make an a:visited rule, with all of the exact same characteristics as your a:link rule! So, in your case, you'd have:

a:visited {
font-family: "Times New Roman", Times, serif;
font-size: 12pt;
font-style: normal;
font-weight: bold;
color: #FF0000;
text-decoration: none
}

Notice that it's exactly the same as the a:link rule, except for the first word, obviously.

Before I close this up though, I think that there are a lot of things that you can work on to clean up your style sheet, which is somewhat of a mess! ;)

First off, you really should have a "body" rule in place, so that you can eliminate all of those redundancies. Remember, in CSS, when a child element is within a parent element, it not only follows its own rules set for it, but it also inherits all of its parent elements, unless they're overwritten by a certain specification. So, if you specify in the "body" rule font-family: Times, you will never, ever have to do that again in any other of the various elements, unless you purposely want to overwrite it.

I'll use my CSS for an example:


__________________


body {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 11px;
margin: 0;
padding: 0
}

a:link, a:visited {
color: #006300;
text-decoration: underline
}

a:hover, a:active {
color: #000000;
text-decoration: underline
}

h1 {
font-size: 13px;
font-weight: bold
}

div.normal {
padding: 3%
}

div.slink {
padding: 3%
}

div.slink a:link, div.slink a:visited {
color: #006300;
text-decoration: none
}

div.slink a:hover, div.slink a:active {
color: #000000;
text-decoration: underline
}

h2 {
font-size: 15px;
font-weight: bold;
color: #006300
}

___________

Notice that there are no unnecessary redundances (forget all of the div.slink stuff for one moment)-- for example, all of the "a:" rules don't specify font-size, family, etc., because they automatically inherit the properties of the body rule. In things like h1 and h2, I specify the sizes, weights, etc. because I am purposely changing them. Makes it much simpler, doesn't it?

As for the div.slink rules, if you read it, you'll figure out that it's basically everything that a div.normal rule is (including the inheritance of the "body" properties), but I made it to overwrite the would-be-inherited a: properties, and changed them to not underline when in link and visited stages.

If you need any clarification, please ask! :)

-Sage
 
Oh, and I should add in one more thing:

If you want full control of your CSS, I personally don't think that using Dreamweaver's built-in CSS support is a good idea-- it's kind of crappy (not to badmouth Dreamweaver though... it's otherwise a great, top-notch program).

I personally just open up my CSS document, and type straight in it. It offers a lot more control, and the fact that Dreamweaver will "wrongly" color something if the syntax is wrong makes it relatively easy to spot mistakes. 👍

I personally would highly recommend Elizabeth Castro's HTML for the World Wide Web, 5th Edition, With XHTML and CSS... it's a totally up-to-date book, and is full with every single thing you need to know about (X)HTML and CSS, even if you use Dreamweaver's WYSIWYG interface-- I don't know where I'd be without that book. :) It even has tables in the back for reference to every single (X)HTML and CSS tag/rule used. And it's only 20 bucks.
 
Wow, that's an eyefull youth_cycler! That info is very much appreciated. In regards to the redundant entries, I felt I had the same kinda thing going on myself. I'll talke a look at your suggests and look into the reference material that you suggested. And thanks for taking the time to sort out my apparent CSS mess. :)

:cheers:
 
Originally posted by Pako
Wow, that's an eyefull youth_cycler! That info is very much appreciated... And thanks for taking the time to sort out my apparent CSS mess.
You're welcome! :)

In regards to the redundant entries, I felt I had the same kinda thing going on myself.
Yup... it's really a great time-saver to avoid such redundancies... not only do you have to type less, but if you want to make a site-wide change (font-family for example), you'll only have to do it once ("body" rule), instead of changing every single rule.

I'll talke a look at your suggests and look into the reference material that you suggested.
The book is an absolute steal at $21.99... I'd easily buy it for $40 if that's what was demanded, because it's so clear, concise, and chock full of inormation. Everything is laid out logically, and the quick references in the back are indespensible. I know it sounds like I'm being a salesperson for it (:embarrassed:), but it truly is a top-notch book. 👍

Oh, and, two more note:

I might've used the wrong terminology when making the CSS references (rules, elements, etc.), but I'm assuming that you can still sort of understand what I was trying to say. ;)

Also, in Dreamweaver, when you're making your CSS, put a tab before each specification for a rule. For example,

a:link {
&nbsp; &nbsp; &nbsp; &nbsp; color: #000000;
&nbsp; &nbsp; &nbsp; &nbsp; text-decoration: underline
}

I used non-breaking spaces to make that, but anyway, it makes it even easier to read the sheet, and anyway, Dreamweaver seems to like it better set up like that. :)
 
Heh, one more thing :D :

To fully answer your original question, an even easier way to make a:visited match a:link is to simply combine them into one style rule by using commas. For example, here's mine:

a:link, a:visited {
color: #006300;
text-decoration: underline
}

Again, it's a good time saver, since you'd only have to change the specifications once, and it'll automatically affect them both. :)
 
Once I get into it we'll see. One thing that I don't want to happen is to have the the a:hover to be the dominant over the a:visted and a:link. So that no matter if they've been there before or not. The effect I'm going for is to have all links (and visted) NON-Underlined, Bold, and a particular color. Then I want the a:hover to be underlined so you only see the underline when your "hovering" over a link wheither you've been there before or not. Oh and when they click on the link, it's red when the link is active.

I'll keep you updated as to my progress. :-)

:cheers:
 
Youth_cycler, you seem to have CSS covered. One thing that I'm concerned about is browser support. Do you have any references as to which browsers support CSS?
 
Originally posted by Pako
Once I get into it we'll see. One thing that I don't want to happen is to have the the a:hover to be the dominant over the a:visted and a:link. So that no matter if they've been there before or not. The effect I'm going for is to have all links (and visted) NON-Underlined, Bold, and a particular color. Then I want the a:hover to be underlined so you only see the underline when your "hovering" over a link wheither you've been there before or not. Oh and when they click on the link, it's red when the link is active.
Well, then, don't worry at all! :) Unless a user's computer suddenly has severe RAM shortage right at the exact moment, there's no way that a:hover would "overpower" the others. That's the beauty of CSS-- such great control over everything.

BTW, would you be looking for something like this?:

_______________

a:link, a:visited {
font-weight: bold;
color: #??????;
text-decoration: none
}

a:hover {
font-weight: bold;
color: #??????;
text-decoration: underline
}

a:active {
font-weight: bold;
color: #ff0000;
text-decoration: none
}

_______________

Change it as you like, of course. ;)

_______________

Originally posted by GilesGuthrie
One thing that I'm concerned about is browser support. Do you have any references as to which browsers support CSS?
Here's a chart of browser support for various CSS specifications. Basically, almost every browser in existance supports CSS 1, and approximately 90% of the browsers used today have very, very good support for CSS 2.

Usually, you'll only run into problems when using obscure specifications (such as border-collapse... who on Earth uses that?!?), and then Microsoft has been a little bit stiff in some of the things that it chooses to support, such as position: fixed, which would be the ultimate solution for frames (it allows you to simply affix an element so that it doesn't move, instead of going through the whole mess of frames; unfortunately, like I said, MS has refused to support it :irked:).

If you keep away from the very obscure and the very weird, you should have few problems with backwards-support... most problems occur with IE4 and NS4, which not a whole lot of users are still using.

Since you're really concerned about it, I'd say a good thing to do is to take the middle road-- use CSS for control over design, and maybe wait a while until you use it for layout... right now, it seems that layout has more support problems.
 
Originally posted by youth_cycler
Well, then, don't worry at all! :) Unless a user's computer suddenly has severe RAM shortage right at the exact moment, there's no way that a:hover would "overpower" the others. That's the beauty of CSS-- such great control over everything.

BTW, would you be looking for something like this?:

_______________

a:link, a:visited {
font-weight: bold;
color: #??????;
text-decoration: none
}

a:hover {
font-weight: bold;
color: #??????;
text-decoration: underline
}

a:active {
font-weight: bold;
color: #ff0000;
text-decoration: none
}

_______________

Change it as you like, of course. ;)

*snip*

a:hover {
font-weight: bold;
color: #336699;
text-decoration: underline
}

a:link, a:visited {
font-weight: bold;
color: #336699;
text-decoration: none
}

a:active {
font-weight: bold;
color: #ff0000;
text-decoration: none
}

If a top to bottom hiearchy of dominance works, I would probably want the a:hover to be dominant over the rest of the links, otherwise the text-decoration: none would result in a non-underlined link. Is that right? I'll just have to try it to find out, eh? :D

Thanks agian...
 
Originally posted by Pako
a:hover {
font-weight: bold;
color: #336699;
text-decoration: underline
}

a:link, a:visited {
font-weight: bold;
color: #336699;
text-decoration: none
}

a:active {
font-weight: bold;
color: #ff0000;
text-decoration: none
}

If a top to bottom hiearchy of dominance works, I would probably want the a:hover to be dominant over the rest of the links, otherwise the text-decoration: none would result in a non-underlined link. Is that right? I'll just have to try it to find out, eh? :D
Erm, no. You're over-complicating things. ;) The hierarchy thing doesn't apply at all with the order that you type the CSS, rather, it works through pre-defined elements and other things. For example, every element is a child of the "body" element, not because I put it first in my CSS, but because that's just how the way web pages work-- everything that you see on a webpage (save for the title) is enclosed within the body tag, right? It doesn't matter what order I put the stuff in... the users' web browsers will read them the same way, no matter what.

Ironically though, the one exception is the a: rule, and in fact, you do want to leave it in the order that I wrote it down, otherwise it can cause some confusion on the browser's part.

Don't worry about "overwritting"... you have to understand that browsers treat a:link, a:hover, etc. as totally different things. When a link is sitting there, the browser interpretes it as a:link. When the user mouses over it, the browser interpretes it as a:hover, and will do exactly whatever the a:hover rule tells it to do-- it'll completely ignore whatever the a:link/a:visited/a:active rules say-- it'll only follow the a:link rule (plus anything that it has inherited from its parent element, like font-family, but things like color and text-decoration will have been overwritten by the a:hover rule).

Again, it's really simple, and I think you're over-complicating it a bit. There's no way that the browser will inerprete a dormant link as a hovered-over link, and vice-versa. ;) Same goes with the rest of the a: rules.
 
I love using CSS, but Netscape has issues with it; on Linux machines, for example, CSS doesn't work for me. And IE6 really made you be more careful which commands you use.

To read externally-linked stylesheets on the fly, I made *.css files readable by Notepad (the best CSS editor).
 
Originally posted by pupik
To read externally-linked stylesheets on the fly, I made *.css files readable by Notepad (the best CSS editor).
Ah, but does Notepad color-code the syntax, like Dreamweaver does? ;) (Sorry, I can't check, since I'm not running a Windows machine)
 
Originally posted by youth_cycler
Ah, but does Notepad color-code the syntax, like Dreamweaver does? ;) (Sorry, I can't check, since I'm not running a Windows machine)

No, Notepad is a vanilla text editor.
 
Back