Problem Description
I am working on a business card project and linking an external CSS file (styles.css
) using the <link>
element inside the <head>
section. However, I am getting the following error:
“Your link element should have an href attribute with the value styles.css.”
Here is my <link>
element in index.html
:
<link rel="stylesheet" href="styles.css">
Despite having the correct href
value, the error still persists.
My Code
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Business Card</title>
<link href="styles.css" rel="stylesheet">
</head>
<body>
<div class="business-card">
<img class="profile-image" src="https://cdn.freecodecamp.org/curriculum/labs/flower.jpg" alt="a flower for profile">
<p class="full-name">Your Name</p>
<p class="designation">Software Developer</p>
<p class="company">@freecodecamp</p>
<hr>
<p>Email: your-email@example.com</p>
<p>Phone: (123) 456-7890</p>
<a href="http://example.com/">Portfolio</a><hr>
<div class="social-media">
<h2>Connect with me</h2>
<span><a href="www.twitter.com">Twitter</a></span>
<span><a href="www.linkedln.com">LinkedIn</a></span>
<span><a href="www.github.com">GitHub</a></span>
</div>
</div>
</body>
</html>
CSS
body {
font-family: Arial, sans-serif;
background-color: rosybrown;
}
p {
margin: 5px;
}
a {
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
.business-card {
width: 300px;
padding: 20px;
margin-top: 100px;
background-color: rgb(252, 241, 245);
text-align: center;
font-size: 16px;
margin-left: auto;
margin-right: auto;
}
Troubleshooting Steps Taken
- Checked for Typos in
href
Value:- The
href
value is exactly “styles.css”, matching the CSS file name.
- The
- Cleared Browser Cache & Hard Refreshed:
- Pressed
Cmd + Shift + R (Mac)
to reload without cache.
Question for the Forum:
- Why is the
<link>
element not recognizingstyles.css
even though thehref
value is correct? - Are there hidden issues that might be causing this?
- Could this be an issue with the validation system detecting the
<link>
incorrectly?
Any guidance or debugging suggestions would be appreciated!