Jump to content

Include one style in another


wjw

Recommended Posts

Is there a way to include one style within another for example:.noborder { border: none;}.datafield { /* include noborder style here */ font-weight: bold; . . .}I know I can add several classes in the XHTML (i.e. class="datafield noborder") but have a lot of places where this would greatly help. (okay, I'm just too lazy to type all those class names:)Thanks!

Link to comment
Share on other sites

I don't think so, but I'm not an expert.I would create each class as you need and assign them accordingly.

A better example of how this would be helpful is:.smallText { font-size: 65%;}.dataFieldLabel { .smallText; font-weight: normal; . . .}.dataFieldData { .smallText; font-weight: bold; . . .}That way if I wanted to change the small text size, I'd just modify the .smallText class.It's no big deal as CSS provides other ways of stacking classes but it seems like this way would make sense.Jason
Link to comment
Share on other sites

.smallText {  font-size: 65%;}.dataFieldLabel {    .smallText;    font-weight: normal;    .    .    .}.dataFieldData {   .smallText;   font-weight: bold;   .   .   .}

This is what you'd like, or what worked? If it was my second guess, then I'm really a complete CSS noob :) .As for your problem, I think you can use a single class name twice. Both of the priorities will be appyed, and the ones in the second will take priority if overlapping. For example:
.dataFieldLabel {    font-weight: normal;    .    .    .}.dataFieldLabel {    font-size: 65%;    .    .    .}

This would apply both the font-size and font-weight. But as you can see it's a bit unpractical, especially to include in one stylesheet. Consider using multiple classes in your (X)HTML.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...