jQuery in Action, 2nd edition*
The moose likes HTML, CSS and JavaScript and the fly likes Using Some of attributes from CSS Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Using Some of attributes from CSS" Watch "Using Some of attributes from CSS" New topic
Author

Using Some of attributes from CSS

Azrael Noor
Ranch Hand

Joined: Jul 29, 2010
Posts: 382
I have written a CSS: having 10 attributes for a tag or class

Now i am writing HTML

i will use that div class for specific affect and whole 10 attributes will apply to that objects.

Now if i want to use 8 of that div attributes,

is their any technique that i use same class and could minus two or some of it's attributes?
or have i to write the code again or write internal styles?


Kindly explain


Regards
Azrael Noor
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61092
    
  66

You can override with another class, or use local styles. I tend to avoid the latter as I like to keep the style information completely separate from the structural information.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Azrael Noor
Ranch Hand

Joined: Jul 29, 2010
Posts: 382
I have already made CSS in seperate file, and i have made two classes in it.
i want to some of attributes and ya i am not able to get what are you saying,
Could you please explain it with help of example?
.
.
and ya i haven't find anything on google.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61092
    
  66

It's also possible that your CSS classes are too encompassing. Should they be broken up into smaller units?
Azrael Noor
Ranch Hand

Joined: Jul 29, 2010
Posts: 382
Sir, i am not getting, i want to explain that again what i am trying to say

See what i am doing



and i am incorprating this code into



Now where i will call Style6
all style will be embedded

if i want to use same class style6,
but i just want to use 3 of it's attributes(Width, margin-left, margin-right), instead of five
and
i do not want to write style7, style8 for every <Table> tag.

is their any possibility to incorprate some of attributes of that class,
instead of whole and
rejecting which i donot want to use(padding and border?

if yes than how?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61092
    
  66

No. It's all or nothing. But as I already said, you can override the properties that you want to be something else, or you can break up the classes into a finer grain.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61092
    
  66

Eric posted an example of what I meant by "finer grain". If you make your classes too big and monolithic, they become much less versatile.
Azrael Noor
Ranch Hand

Joined: Jul 29, 2010
Posts: 382
Thanks bear and Eric

So by this you mean

If i want to do this
_______________

.class1
{
background-color: #CFC;
height:50%
}

.class2
{
color: #CFC; //Again
height:100% //Same but different Value
}

________________

i have to make classes again and again,
means it is recommended that for every different attributes
i should make different class

and one more thing for "BEAR"
you said
you can override the properties that you want to be something else


i am not able to understand the statement, could you give an example, please!!!


Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61092
    
  66




What color will the text be?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using Some of attributes from CSS