0

I have wrapper id which i use for my entire page.

html

<div id="wrapper"> </div> 

css

#wrapper{ width: 960px; margin: 0 auto; } 

Now what i want to do is create a class for that id that i will use for pages that has max width full resolution.

html

<div id="wrapper" class="full-width> </di> 

css

#wrapper.full-width{ width: 100%; } 

Is this the right way to do it?

2
  • 4
    As long as you only use an ID once on each page, yes it's fine. Commented Feb 10, 2014 at 2:10
  • 3
    I concur, personally though I'd make wrapper and full-width classes and reserve id for something more meaningful. Unless you are using it as an anchor. Commented Feb 10, 2014 at 2:15

1 Answer 1

1

An ID must be unique, so you can only use it once on a page (which it sounds like you are doing).

Depending on the specific case, I would probably be inclined to make the ID and the class separate tags (the div class="full-width" being nested inside the wrapper), especially if the ID wrapper would be used on various pages, but the class might be different. That gives you more flexibility within the wrapper ID.

Doing that, you could still do the CSS the way you have it.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.