473,651 Members | 2,917 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multiple Classes in "class" ok?

Can someone clarify that multiple classes in the "class" attribute are ok
and "legal" and not some fluke?

So, I can do:

..pink {color: pink}
..bold {font-weight: bold}
..medium {font-size: 12pt}

<p class="bold pink medium">bold pink medium sized text</p>

You can use multiple classes, but not multiple id's, so id="this that other"
is wrong.

Most every example of classes only asserts one class.

Thanx!

Regards,

Will Hartung
(wi***@msoft.co m)
Jul 21 '05 #1
32 3387
On Thu, 3 Feb 2005 10:47:18 -0800, Will Hartung <wi***@msoft.co m> wrote:
Can someone clarify that multiple classes in the "class" attribute are ok
and "legal" and not some fluke?

They are 'legal', yes, as gets explained in this group about fifty times a year
:-(
So, I can do:

.pink {color: pink}
.bold {font-weight: bold}
.medium {font-size: 12pt}

No, you can't. Again, as gets explained in this group about fifty times a year,
using pt as unit for font-size is a bad idea. Google for the reason.
<p class="bold pink medium">bold pink medium sized text</p>

Well, this could be okay. I do not like your choice of selectors, class names
though. Use something semantic so you remember why you put a class with an
element. And be very careful with names that are attributes, properties, values,
what ever. Confusion is close by if you do that.
You can use multiple classes, but not multiple id's, so id="this that other"
is wrong.


What would be the use? How would you refer to the element with a multiple id?
You could however write id="this" class="that other".

I'm actually not really sure if one can use multiple values for one id
attribute. Maybe someone else. I don't want to go Google for it or dig down
<http://www.w3.org/TR/html401/struct/global.html#ade f-id>. Maybe you can look
there yourself.

--
,-- --<--@ -- PretLetters: 'woest wyf', met vele interesses: ----------.
| weblog | http://home.wanadoo.nl/b.de.zoete/_private/weblog.html |
| webontwerp | http://home.wanadoo.nl/b.de.zoete/html/webontwerp.html |
|zweefvliegen | http://home.wanadoo.nl/b.de.zoete/html/vliegen.html |
`-------------------------------------------------- --<--@ ------------'
Jul 21 '05 #2
/Barbara de Zoete/:
On Thu, 3 Feb 2005 10:47:18 -0800, Will Hartung <wi***@msoft.co m> wrote:
Can someone clarify that multiple classes in the "class" attribute are ok
and "legal" and not some fluke?


They are 'legal', yes, as gets explained in this group about fifty times
a year :-(


It's a damn good number ("fifty per year"), I think. :-)

--
Stanimir
Jul 21 '05 #3
Barbara de Zoete wrote:
On Thu, 3 Feb 2005 10:47:18 -0800, Will Hartung <wi***@msoft.co m>
wrote:
[snip]
So, I can do:

.pink {color: pink}
.bold {font-weight: bold}
.medium {font-size: 12pt}


No, you can't.


That's rather misleading on two levels. First, I initially assumed you
were objecting to syntax, however there's nothing wrong in that
respect. I think you could have phrased your objection better. Second,
the OP *can* use pt units, but what one can do and what one *should*
do can be very different things.
I'm actually not really sure if one can use multiple values for one
id attribute.


It doesn't make any sense to do so. An id is a unique value so what
could be gained by having more than one of them? Moreover, the ID data
type doesn't permit spaces so a space-separated list wouldn't be possible.

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 21 '05 #4
"Barbara de Zoete" <b_********@hot mail.com> wrote:
I'm actually not really sure if one can use multiple values for one id
attribute.


Nope (and multiple id attributes is also not valid :)

--
Spartanicus
Jul 21 '05 #5

"Michael Winter" <m.******@bluey onder.co.invali d> wrote in message
news:b3******** ********@text.n ews.blueyonder. co.uk...
Barbara de Zoete wrote:
On Thu, 3 Feb 2005 10:47:18 -0800, Will Hartung <wi***@msoft.co m>
wrote:


[snip]
So, I can do:

.pink {color: pink}
>> .bold {font-weight: bold}
>> .medium {font-size: 12pt}


No, you can't.


That's rather misleading on two levels. First, I initially assumed you
were objecting to syntax, however there's nothing wrong in that
respect. I think you could have phrased your objection better. Second,
the OP *can* use pt units, but what one can do and what one *should*
do can be very different things.


Funny, I WAS going to put:

..medium {font-size: 12px}

But I figured I would get screamed at, even though I was just curious about
the syntax and contrived an example.

Regards,

Will Hartung
(wi***@msoft.co m)
Jul 21 '05 #6
In article <36************ *@individual.ne t>,
Will Hartung <wi***@msoft.co m> wrote:
Can someone clarify that multiple classes in the "class" attribute are ok
and "legal" and not some fluke?

So, I can do:

.pink {color: pink}
.bold {font-weight: bold}
.medium {font-size: 12pt}

<p class="bold pink medium">bold pink medium sized text</p>

(snip)

Yes, that's fine - certainly it's in the CSS2.1 specification.
Browser support may be another matter: ISTR there's at least one
common browser that has problems with it, but I forget which.

-- Mark
Jul 21 '05 #7
Mark Carroll wrote:

[snip]
ISTR there's at least one common browser that has problems with it,
but I forget which.


Both NN4 and IE4 fail to respect multiple class names. No style is
applied in that case. However, I wouldn't call either "common". I'm
not sure if other user agents act similarly.

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 21 '05 #8
in comp.infosystem s.www.authoring.stylesheets, Mark Carroll wrote:
In article <36************ *@individual.ne t>,
Will Hartung <wi***@msoft.co m> wrote:
Can someone clarify that multiple classes in the "class" attribute are ok
and "legal" and not some fluke?

So, I can do:

.pink {color: pink}
.bold {font-weight: bold}
.medium {font-size: 12pt}

<p class="bold pink medium">bold pink medium sized text</p>

(snip)

Yes, that's fine - certainly it's in the CSS2.1 specification.
Browser support may be another matter: ISTR there's at least one
common browser that has problems with it, but I forget which.


Not with that syntax, I believe, but things like .pink.bold {
color:yellow;fo nt-weigh:normal;} don't work as well.

--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Utrecht, NL.
Jul 21 '05 #9

"Mark Carroll" <ma***@chiark.g reenend.org.uk> wrote in message
news:Sc*******@ news.chiark.gre enend.org.uk...
In article <36************ *@individual.ne t>,
Will Hartung <wi***@msoft.co m> wrote:
Can someone clarify that multiple classes in the "class" attribute are
ok
and "legal" and not some fluke?

So, I can do:

.pink {color: pink}
.bold {font-weight: bold}
.medium {font-size: 12pt}

<p class="bold pink medium">bold pink medium sized text</p>

(snip)

Yes, that's fine - certainly it's in the CSS2.1 specification.
Browser support may be another matter: ISTR there's at least one
common browser that has problems with it, but I forget which.

-- Mark


Mark,

My "not-so-original" multiple classes ( class="navy small justify" )
seem to work fine with IE6 and Firefox. Doesn't that cover about 75% of
the World? Pages and CSS validate at W3C.

Del Ferguson

Jul 21 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5662
by: Peter King | last post by:
if you assign multiple classes in order to keep your classes generic e.g ..classA { position.absolute; left:5 top:5 height:200 width:800 } ..classB { background-color: red} ..classC { background-color: green} <div id="div1" class="classA classB" ... but then want to dynamically assign a new class
8
11435
by: kevin | last post by:
I have a form and in the form I have a sub that uses a class I instantiate using visual basic code: Public oCP As New Rs232 'instantiate the comm port I need to share this sub with another form so to declare the sub I use visual basic code: Public Shared Function IsPortAvailable(ByVal ComPort As Integer) As Boolean
5
1953
by: Rob | last post by:
In many articles related to VB.net the word "class" is used... How many meanings are there to this word ? "possible to derived a class from another" "forms are full-fledged classes" "base class"
3
1838
by: Giggle Girl | last post by:
I have inherited some CSS from a former employee that has code like this: onmouseover="this.className='highlight_on standard_border'" where it appears to activate two different classes, "highlight_on" and "standard_border". Is this valid CSS?
11
41075
by: Kimmo Laine | last post by:
I'm flipping my wig here, people. I'm using classes and making each class a file. when I'm including dependet classess, I use require_once to avoid multiple declarations - yet they happen. I put debug_print_backtrace in the file to see how it is included, and here's the output: #0 require_once() called at #1 require_once(\eKirje.textGrid.class.php) called at #0 require_once() called at #1 require_once(\eKirje.kanava.class.php)...
4
1465
by: Christian Joergensen | last post by:
Hello I stumpled upon this "feature" during my work tonight, and found it a bit confusing: .... class C: .... foobar = 42 .... .... <class __main__.C at 0xb7cf735c>
3
1661
by: Ravi | last post by:
Is this the correct way to think of "base class"? The "base class" is a class from which other classes are derived. The "base class" will never be derived from another class.
0
8357
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8700
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8465
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6158
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5612
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4285
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2701
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1910
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1588
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.