/    Sign up×
Community /Pin to ProfileBookmark

Link states in HTML and CSS

Hi!
So I’m completing some exercises with HTML and CSS and currently I’m having trouble with link states. I’m using Google Chrome and Sublime Text as the editor. I feel as though something is overriding the CSS code.

Here’s the CSS:

[code]
#nav{
border:1px solid black;
height: 50px;
width: 300px;
background-color: white;
margin: 0px auto;
}
#nav ul{
list-style-type: none;
}

#nav ul li{
border: 1px solid black;
width: 70px;
display: inline;
padding: 10px;
}
#nav ul li a: link{
text-decoration: none;
}
#nav ul li a:visited{
text-decoration: none;
color: blue;
}
#nav ul li a: hover{
text-decoration: none;
font-weight: bold;
}
#nav ul li a: active{
text-decoration: none;
}
[/code]

And here’s the HTML(top portion):

[code]
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”>

<html>
<head>

<link rel=”stylesheet” type=”text/css” href=”style.css” />

<title>Contact</title>

</head>

<body>

<h1>Contact</h1>

<div id=”nav”>
<ul>
<li><a href=”index.html”>Homepage</a></li>
<li><a href=”about.html”>About</a></li>
<li><a href=”contact.html”>Contact</a></li>
</ul>
</div>
[/code]

Any help would be appreciated! πŸ˜‰

__(Added `[code]…[/code]` tags ~ MOD)__

to post a comment
CSSFull-stack DeveloperHTML

5 Comments(s) ↴

Copy linkTweet thisAlerts:
@NogDogApr 10.2019 β€”Β First thing I'd do is view it in Firefox or Chrome with their developer tools turned on, and make sure it's actually finding/loading the css file. :) If that's not the issue, then I'll leave it to the client-side experts here to do further diagnosis -- or you could try the w3.org validators: https://validator.w3.org/ and https://jigsaw.w3.org/css-validator/ .
Copy linkTweet thisAlerts:
@GhiadevauthorApr 10.2019 β€”Β @NogDog#1602699 The validator really helped! Apparently since I'm self-teaching I'm mixing HTML4 and HTML5 which is why I received some errors there. I'm guessing that this would overrride any CSS styling?

<edit>

It's fixed!Too much spacing, plus the validators found a few errors! Thanks so much :)

</edit>
Copy linkTweet thisAlerts:
@tracknutApr 10.2019 β€”Β If you didn't spot the validator errors on your css, it's showing that you can't have spaces between the colon and the state. For ex, "a: hover" needs to be "a:hover", etc.

You really should be starting off learning html5 at this point. Declaring a document, in 2019, as html 4.01 transitional, with loose validation, is a no-no. You're not transitioning from anything - you are writing brand new code.
Copy linkTweet thisAlerts:
@GhiadevauthorApr 11.2019 β€”Β @tracknut#1602701 Thanks ! I was trying to follow a course but I'm guessing it's a bit outdated. I was pretty confused on why he wanted to declare it transitional. Makes sense though, I've been trying to be consistent in HTML5, but that put me off a bit. Any other things I should try to focus on specifically based on the code above?
Copy linkTweet thisAlerts:
@VITSUSAApr 11.2019 β€”Β I agree with Tracknut, You should learn html 5 again.
Γ—

Success!

Help @Ghiadev spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 β€” BETA 4.23,
whats_new: community page,
up_next: more Davinciβ€’003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinciβ€’003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...