CSS - Which is better: using "main a" or creating a new class?
P粉340264283
P粉340264283 2023-09-07 13:29:36
0
1
603

I am a complete beginner.

I'm making the CSS for the page. I have links in the main menu and I created a class for them.

I then went to configure the main text link and noticed that the changes I made to the a tag also affected my menu.

I thought of two ways to solve this problem:

I can create a new class and put all the links in the body, or I can specify that I only want the "a" tag in "main", which way is considered good practice?

main a{
css;
}

or

.links-main{
css;
}

Both solutions are valid and I would like advice from experienced colleagues on what would be a standard approach.

P粉340264283
P粉340264283

reply all(1)
P粉793532469

When I use CSS I usually try to create a class for these types of things unless I'm almost 100% sure I won't need it in the future. If you don't think there will be more than one applicable class in .main then it should be fine. However, a common approach I've seen is just taking a new class. As Alloch said, a lot depends on your own wishes.

When referencing a class, also make sure to execute .main and not just main.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template