Issue when clicking Link

A minor annoying problem…

In my Page Header, I have this welcome…

if (isset($_SESSION['loggedIn']) && $_SESSION['loggedIn'] == TRUE){
	// Logged In.
	// Display Member Welcome.
	echo "<div id='welcome'>
		<span>Hello, <a id='firstName' href='/account/profile.php'>" . htmlspecialchars($memberFirstName, ENT_QUOTES) . "</a>!</span>
	// Not Logged In.
	// Display Visitor Welcome.
	echo '<div id="welcome">
			<a href="/account/log_in.php">Log In</a> to access premium content. &nbsp;
					Not a Member? &nbsp;<a href="/account/create_account.php">Start Here</a>

And these styles…

#welcome span,
#welcome a#firstName{
	font-weight: bold;
	color: #FF9900;						/* Orange */

When a person is NOT logged in, I want the hyperlinks to be normal, blue, underlined.

When a person is logged in, I want the Username to be bold, orange, underlined so it matches the word "Welcome, "

I seem to have accomplished this, however, if you click on the hyperlink when you are NOT logged in and then drag your cursor off the link - so it doesn’t fire - then the hyperlink turns and stays ORANGE which is annoying…

What is going on?

And is there maybe a better way to do my CSS so things are cleaner and don’t act weird like they are now??

Attached is a Before, During, and After screen-shot…



I am guessing here since you posted only a small snippet of your code. But I think you have a rule somewhere for visited links which is what is turning your links orange a you described.

I think your nested ID selector is overkill. IDs are unique. If the rest of your code is done correctly, you should only need:

#welcome span, #firstName{...}

you could stream line your PHP as well:

<div id='welcome'>
<? echo (isset($_SESSION['loggedIn']) && $_SESSION['loggedIn']) ? 
        "<span>Hello, <a id='firstName' href='/account/profile.php'>" . htmlspecialchars($memberFirstName, ENT_QUOTES) . "</a>!</span>":
        "<span>Hello.</span>&nbsp;<a href='/account/log_in.php'>Log In</a> to access premium content. &nbsp; Not a Member? &nbsp; <a href='/account/create_account.php'>Start Here</a>";


How do you set visited links?

BTW, would it look weird to have things styles like this…

Hello, Debbie!

…versus like how I am trying below…

Hello, Debbie!

(All of this started when I added a hyperlink behind the username tonight so there is an easy way to get to the Member’s Profile…)



#welcome span, #firstName,#firstName:visited{…} should do it.

All of this started when I added a hyperlink behind the username tonight so there is an easy way to get to the Member’s Profile…)

Makes sense, as :visited is UNIQUE to anchor links. :slight_smile:

Hope that helps.

Gonna answer my other question???


The first option is definitely the far better method as it’s clear and concise, people will much more easily recognize that they’ve visited that link before whereas the underline in the second example isn’t obvious enough.

Personally, I never bother with visited styles any more. I don’t like them much, except on sites like Google, where it’s handy to know where you’ve been. You can choose whatever colors you like for visited links, but there’s no guarantee that people will know what that color means—unless perhaps your links are blue by default and turn purple once visited … the usual browser default.

He just answered you question. You have to add pseudo styles to your html element.

Example of pseudo attributes you can use:

color: #FF0000;
/* unvisited link /
color: #00FF00;
visited link /
color: #FF00FF;
mouse over link /
color: #0000FF;
selected link */

So it sounds like we have votes for the two-tones Welcome…

Hello, Debbie!