0

I want to change the padding of 2/6 pages in my website, but the content divs of the website are using the same CSS, the only solution I can think of is changing the id's of all the content divs and make separate CSS for all of them. Is there an easier way to do this?

Repub619
  • 69
  • 2
  • 9

3 Answers3

0

You could create a new class and apply it to only the places you want changed.

.pad-class{
  padding:5px;
}

<div class="other-class pad-class"></div>

Placing the class last will allow for your new class to overwrite the first one.

Niles Tanner
  • 3,911
  • 2
  • 17
  • 29
0

You should just apply a specific class to the <body> tag of the pages you want to modify. Then you can write a CSS rule for that class.

HTML (normal page)

<body>
  ...
</body>

HTML (different padding page)

<body class="different-padding">
  ...
</body>

CSS

<style>
body { padding: 10px; }
body.different-padding { padding: 20px; } 
</style>
0
<div class="first second"></div>

Insert second where you want to change padding else keep only single class further reference: Using two CSS classes on one element

you can also use inline styling if no. of divs are less

abhishekrn
  • 79
  • 8