WhilseySoon
WhilseySoon

Reputation: 322

Using IDs in LESS

I've started using LESS recently and it's really convenient, and I have a question: as it's really convenient to place element inside the brackets to clarify the style structure, in .CSS file that's being generated I end up seeing things like this:

#second-block .side-menu #category .content{...}

Is this okay to have id elements inside other id elements, even though I use LESS?

Upvotes: 1

Views: 1716

Answers (1)

Alex Johnson
Alex Johnson

Reputation: 1574

Yes. It's ok to have id element inside other id elements.

The generated .css will work.

Personally, I like to use as few id elements in my code as possible. The reasoning behind this, is how some browsers don't like it when you have multiple instances of the same id on the page. I find that using classes is more flexible.

Here's a relevant stack overflow question that mentions on ids vs. classes:

Is there any pros and cons if i use always CSS Class instead CSS ID for everything?

Upvotes: 1

Related Questions