First of all, IDs are unique elements, and you should only have 1 per page.
To apply the same style to multiple elements, you must use a class.
<div class="name-of-my-common-style">
And then from css, use a period (.) Instead of a hash (#) to define the style for this class. i.e.
.name-of-my-common-style { position:absolute; top:200px; left:200px; width:200px; height:200px; }
To override any styles, you can use inline CSS
<div class="name-of-my-common-style" style="width: 150px"> ... </div>
This will take the original styles from name-of-my-common-style , but override the width due to the built-in width parameter of 150px .
Another approach is to create a separate class for each width declaration and apply it to the element. i.e.
.name-of-my-common-style { ..default styles here..} .width-150 {width: 150px;} .width-200 {width: 200px;}
And so on...
Then you can use it like this.
<div class="name-of-my-common-style width-150">I'm 150px wide</div>
Hope this helps.
Marko source share