-2

So i am relatively new to CSS so im sorry if this question is a stupid one but what is "a" that is written after a class as seen below?

    .topnav {
  background-color:  black;
  overflow: hidden;
  position: -webkit-sticky;
  position: sticky;
  top: 0;
}


.topnav a {
  float: right;
  color: white;
  text-align: center;
  padding: 35px 20px;
  
  font-size: 21px;
  text-decoration:none;
  text-decoration: underline 0.10em rgba(255, 255, 255, 0);
  background-image: linear-gradient(#000, #000);

}


.topnav a:hover {
  
  
  background-color:rgb(59, 59, 59);
  transition:text-decoration 300ms;
  
 
  text-decoration-color: white;
}

3 Answers3

5

It's every <a> tag inside the element with the class name. In this case it's every <a>inside .topnav element. If you are not sure, I like to set borders in CSS and then you can see what is affected by the CSS rule and what is not

.topnav a {
  border: solid 2px fuchsia;

}
<div class="topnav">
  <a>fuchsia border</a>
  <div class="hey">
     <a>fuchsia border</a>
  </div>
</div>
<a>not affected</a>

CSS: Cascading Style Sheets it's definitely worth a read (start with the tutorials)

caramba
  • 21,963
  • 19
  • 86
  • 127
1

It denotes the tag inside another HTML element with the class name topnav. For an example, it may look like this:

<div class="topnav">
     <a>Link 1 </a>
</div>

a tag has specific properties like hover which denotes the different aspects of the tag

Thiluxan
  • 177
  • 4
  • 13
1

im assuming you are talking about the a in the .topnav a

it means its styling the <a> tag in the element with the class topnav

for example i have a div with class of topnav and it has an <a> tag inside it like this

<div class= "topnav">
   <a>hi</a>
</div>

the .topnav a in css will apply the style to this <a>hi</a> element

I_love_vegetables
  • 1,575
  • 5
  • 12
  • 26