I am working on the menu bar of a website.
I am using nextjs for my application
I want to style the a tag
but it did not work
My code
Javascript
const Nav = () => {
return (
<div className={styles.nav}>
<div className={styles.topNav}>
<div className="d-flex justify-content-between">
<div>
<Link href="/">
<a>
Logo
</a>
</Link>
</div>
<div className={styles.navLinks}>
</div>
<div onClick={openMenu} className={styles.menuHamburger}>Menu</div>
</div>
</div>
</div>
)
}
CSS
.topNav{
background-color: blue;
padding: 1.5rem 1rem;
}
.topNav > div > a{
color: white;
}
You used the child selector > in .topNav > div > a, meaning you're only styling an <a> that is the child of a <div> that is the child of an element with the .topNav class. Your <a> is only a descendant here. You can use a space instead to specify any descendant: .topNav > div a