MeltingDog MeltingDog - 24 days ago 5
Sass (Sass) Question

What is the right way to style an element with multiple selectors in SASS?

I have some elements as such:

<div class="logo">
<a href="#">LOGO HERE</a>
</div>


Considering the
a
tag is the only element within
.logo
is it still appropriate to write the SASS as:

.logo {
a {
//STYLES
}
}


Or is normal css ok here? Eg:

.logo a {
//STYLES
}


Both ways work, of course, but is there a preferred way when working with SASS?

Answer

Both will work fine in SASS. Traditionally, for readability, it's better to nest the elements, as you've listed in the first example.