Hi good day every one I am a beginner in html and css can anybody help me here of my code because i want to change the color of font in to black and the font size of my navbar but I couldn’t change my code is in below
My HTML code:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title> shoe Website</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="homepage.css">
</head>
<body>
<div class="top-header">
<a href="">About us</a>
<a href="">Privacy Policy</a>
<a href="">Contact us</a>
<a href="">Terms of use</a>
<div class="middle"> </div>
<div class="space-end"></div>
</div>
<div class="navbar">
<div class="logo">
<img src="images/Screenshot 2023-07-09 162710.png">
</div>
<div class="navbar">
<ul>
<li> <a href="">Home</a></li>
<li> <a href="">Shop</a></li>
<li> <a href="">Pages</a></li>
<li> <a href=""> Contact</a></li>
</ul>
</div>
</div>
</body>
</html>
this is my CSS code
@import url('https://fonts.googleapis.com/css2?family=Poppins&display=swap');
.top-header{
display: flex;
flex-direction: row;
justify-content: space-between;
background-color: #343a40;
height: 40px;
width: 100%;
margin: 0;
padding-left: 20px;
align-items: center;
margin-bottom: 30px;
}
a{
font-family: 'Poppins', sans-serif;
width: 120px;
text-align: center;
font-size: 13px;
text-decoration: none;
color: #F4EEE0;
margin: 0;
}
a:hover{
color: #176B87;
transition: 0.3s ease;
}
body, html{
margin: 0;
margin: 0;
}
.navbar{
display: flex;
flex-direction: row;
}
.logo{
padding-left: 30px;
width: 500px;
}
ul, li{
list-style-type: none;
display: flex;
color: #000000;
}
I would like to expect that to change the color and the fonts of "Home, Shop , Pages, and Contact."
@import url('https://fonts.googleapis.com/css2?family=Poppins&display=swap');
.top-header{
display: flex;
flex-direction: row;
justify-content: space-between;
background-color: #343a40;
height: 40px;
width: 100%;
margin: 0;
padding-left: 20px;
align-items: center;
margin-bottom: 30px;
}
a{
font-family: 'Poppins', sans-serif;
width: 120px;
text-align: center;
font-size: 13px;
text-decoration: none;
color: #F4EEE0;
margin: 0;
}
a:hover{
color: #176B87;
transition: 0.3s ease;
}
body, html{
margin: 0;
margin: 0;
}
.navbar{
display: flex;
flex-direction: row;
}
.logo{
padding-left: 30px;
width: 500px;
}
ul, li{
list-style-type: none;
display: flex;
color: #000000;
}
<div class="top-header">
<a href="">About us</a>
<a href="">Privacy Policy</a>
<a href="">Contact us</a>
<a href="">Terms of use</a>
<div class="middle"> </div>
<div class="space-end"></div>
</div>
<div class="navbar">
<div class="logo">
</div>
<div class="navbar">
<ul>
<li> <a href="">Home</a></li>
<li> <a href="">Shop</a></li>
<li> <a href="">Pages</a></li>
<li> <a href=""> Contact</a></li>
</ul>
</div>
</div>
2
Answers
You have to import your CSS into your document.
See Link Element for more info.
You are trying to change the color of
a
elements that are insideli
elements by adding a color toli
. That is not going to work because of css specificity ( you already add a color toa
in your CSS file )So, ‘ be more specific ‘ . You have 2 options:
ul li a { color: ... }
and that will change the color of your desired elements. and delete thecolor
rule fromul li
ul li a { color: inherit }
which will inherit the color from the parent