W3C home > Mailing lists > Public > www-style@w3.org > July 2000

Re: Giving a class the same values as another class

From: <pdf@bizfon.com>
Date: Tue, 25 Jul 2000 17:21:16 -0400
To: "John Lewis" <john@gleemax.com>
cc: www-style@w3.org
Message-ID: <85256927.00754E30.00@Enterprise>


This solution would ultimately be appending to the global style, which is what I
would be trying to avoid.  What if you need to use that global style on more
than one item on the page?  Your additions would be applied to those other items
as well.

Fortunately, Chris Lilley pointed out that in fact you CAN apply more than one
class to an element (by giving the 'class' value a space delimited list of
classes).  This is what I was trying to do because I wanted to leave my global
styles intact for the rest of the items on the page.  So the solution then is:

/* site.css */
.globalproperties { font-family: helvetica,sans-serif; }


<html>
<head>
<title>Hello World</title>
<link rel="stylesheet"  type="text/css" href="site.css">
<style type="text/css">
.localproperties { color: red; }
</style>
</head>
<body>
<table>
     <tr>
          <td class="globalproperties localproperties">This is now RED and
HELVETICA!</td>
     </tr>
</table>
</body>
</html>

Thanks!
PS- IDs can not be used on multiple elements... that's what classes are for. :)






"John Lewis" <gleemax@hotpop.com> on 11/25/99 04:48:38 PM

Please respond to "John Lewis" <john@gleemax.com>

To:   www-style@w3.org
cc:    (bcc: Peter Foti)

Subject:  Re: Giving a class the same values as another class



Sorry, I did make a mistake. I don't know why I linked AND imported the
style sheet...must be lack of sleep. But if you look closer you'll see
that I also explained the difference.

1. Import (or link, it doesn't matter) the base style sheet rules
2. Append (or add) the "color: red;" declaration to the local page (the
global style sheets rules should still apply (unless you choose to
override them), correct?

Oh, and now that I think about, you could maybe use an id for the local
page (can ids be used on multiple elements, or is that not kosher?).

----- Original Message -----
From: <pdf@bizfon.com>
To: "John Lewis" <john@gleemax.com>
Cc: <www-style@w3.org>
Sent: Tuesday, July 25, 2000 2:39 PM
Subject: Re: Giving a class the same values as another class


:
:
: I'm not quite sure I understand your solution.  :)
: It looks like you are simply including the global style sheet twice
(using two
: different methods) and then modifying the global style.  That's not
what I'm
: trying to do.  I want a local class which has the same characteristics
as a
: global class, without modifying the global class (so that the global
class can
: be used elsewhere on this page).
: Pete
:
:
:
:
:
: "John Lewis" <gleemax@hotpop.com> on 11/25/99 04:11:37 PM
:
: Please respond to "John Lewis" <john@gleemax.com>
:
: To:   www-style@w3.org
: cc:    (bcc: Peter Foti)
:
: Subject:  Re: Giving a class the same values as another class
:
:
:
: I'm not quite sure I understand your problem, but I have a possible
: solution:
:
: /* site.css */
: globalproperties { font-family: helvetica,sans-serif; }
:
:
: <html>
: <head>
: <title>Hello World</title>
: <link rel="stylesheet"  type="text/css" href="site.css">
: <style type="text/css">
: @import url(site.css)
: /* import the rules defined in site.css */
: globalproperties { color: red; }
: /* and append the local declarations to the selector */
: </style>
: </head>
: <body>
: <table>
:      <tr>
:           <td class="globalproperties">This is now RED and ARIAL!</td>
:      </tr>
: </table>
: </body>
: </html>
:
:
: ----- Original Message -----
: From: <pdf@bizfon.com>
: To: <www-style@w3.org>
: Sent: Tuesday, July 25, 2000 1:37 PM
: Subject: Giving a class the same values as another class
:
:
: :
: :
: : Is it possible (or are there any plans to make it possible) to
include
: the
: : properties of one class inside the properties of another?  For
: example, suppose
: : I have a page that is part of a site.  There are certain site wide
: properties
: : that I may assign through a class (for example, if I want certain
: items
: : throughout the site to use a particular font).  But there are also
: properties
: : that are specific to that page that I don't want to be given to the
: entire site.
: : Those properties would be defined in a class that was local to that
: page only.
: : You can't declare something as having multiple classes (not that I
: know of
: : anyway), so it would be nice to be able to do something like this:
: :
: : /* site.css */
: : /* This is a global style, used throughout the site */
: : globalproperties { font-family: helvetica,sans-serif; }
: :
: :
: :
: : <html>
: : <head>
: : <title>Hello World</title>
: : <link rel="stylesheet"  type="text/css" href="site.css">
: : <style type="text/css">
: : /* This is my local style, used on this page only */
: : /* Would be nice to INCLUDE global class in my local class like so
*/
: : localproperties { color: red; classname: globalproperties; }
: : </style>
: : </head>
: : <body>
: : <table>
: :      <tr>
: :           <td class="localproperties">This is now RED and
ARIAL!</td>
: :      </tr>
: : </table>
: : </body>
: : </html>
: :
: :
: :
: : This is a very simplified example, but I think it gets my question
: across.  I
: : haven't seen any way to do something like this.  Is it possible?
Will
: it be
: : possible in the future?
: : Thanks,
: : Peter Foti
:
:
:
:
:
:
:
:
: ____________________________________________________________
: Get your FREE personal .com domain name and
: NAMEzero Personal Portal at: http://www.namezero.com.
: For customer service, mailto:customerservice@namezero.com.
:
:
Received on Tuesday, 25 July 2000 17:21:38 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:05 GMT