/    Sign up×
Community /Pin to ProfileBookmark

Overriding Class Style

I have a lot of DIV tags on a web page. And they all defined by either Class A or Class B.

One tag might look like this:

[CODE]<div class=”a”>…</div>[/CODE]

The majority of my tags are class A, and only a hand full are class B.

I’m thinking a great way to slim down my code would be to have all DIV tags defined as class A style, and the handful of B tags have class B style.

Would this work or is it bad form?

I’m thinking about something like this:

[CODE]<style>
div{…class A style…}
.b{…class B style…}
</style>

<div>…</div>
<div>…</div>
<div>…</div>
<div>…</div>
<div class=”b”>…</div>[/CODE]

What does everyone think?

to post a comment
CSS

4 Comments(s)

Copy linkTweet thisAlerts:
@JupacMar 05.2005 — Yea... It looks good
Copy linkTweet thisAlerts:
@TriumphMar 05.2005 — I guess it all depends on if you need the div tags or not. Could be good. Could be junk markup. Let's see your work.
Copy linkTweet thisAlerts:
@shopkanjiauthorMar 05.2005 — My site is http://www.printfreegraphpaper.com and my CSS DIV tags I am talking about are:

[CODE].fl{float:left;width:18%;padding-left:2.5em}
.nl{float:none;padding-left:2.5em}[/CODE]
I tried to make .fl the DIV tag default and got rid of all the "fl" classes, but it didn't seem to work. It didn't play nice with my images.
Copy linkTweet thisAlerts:
@NutterMar 05.2005 — Sure it'd work. Although, my first thought was that naming your classes A and B can lead to confusion. Maybe a default div {yada: yada;} and div.alt {yahoo: yahoo;}? That way your alternate div would have a name more fitting.
×

Success!

Help @shopkanji spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...