473,399 Members | 4,254 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

CSS: question about colons

I apologize if this is the wrong group, but my usenet provider doesn't
carry any CSS-specific groups, and people in this group are likely to be
CSS experts anyhow.

My question is this:
In HTML, the "id" attribute of an element can legally contain a colon
character (":"). In a CSS declaration, how is this distinguished from a
pseudoclass specifier?

For example, if I have the following element

<strong id="Foo:Bar">something</strong>

And the following CSS to style it:

strong#Foo:Bar
{
some-rule: some-value;
}

It seems like the browser would think I'm trying to use a "Bar"
pseudoclass for the selector "strong@Foo".

So is it a bad idea to use colons in an element id, even though they're
perfectly legal? Is there some other way to specify this in CSS?

Thanks,
Jeremy
Aug 8 '06 #1
9 1610
Deciding to do something for the good of humanity, Jeremy
<je****@pinacol.comdeclared in comp.infosystems.www.authoring.html:
I apologize if this is the wrong group, but my usenet provider doesn't
carry any CSS-specific groups, and people in this group are likely to be
CSS experts anyhow.
news://comp.infosystems.www.authoring.stylesheets is the group for CSS.
So is it a bad idea to use colons in an element id, even though they're
perfectly legal?
Yes.
Is there some other way to specify this in CSS?
You could escape it, as with any other character:

strong#foo\:Bar

but what browser support will be like is questionable. Better to avoid
using it in the first place.

--
Mark Parnell
My Usenet is improved; yours could be too:
http://blinkynet.net/comp/uip5.html
Aug 8 '06 #2
Mark Parnell wrote:
Deciding to do something for the good of humanity, Jeremy
<je****@pinacol.comdeclared in comp.infosystems.www.authoring.html:
>I apologize if this is the wrong group, but my usenet provider doesn't
carry any CSS-specific groups, and people in this group are likely to be
CSS experts anyhow.

news://comp.infosystems.www.authoring.stylesheets is the group for CSS.
Thanks for this. I hadn't thought to look for "stylesheets" instead of
"css".
>So is it a bad idea to use colons in an element id, even though they're
perfectly legal?

Yes.
>Is there some other way to specify this in CSS?

You could escape it, as with any other character:

strong#foo\:Bar

but what browser support will be like is questionable. Better to avoid
using it in the first place.
You're probably right. I ran a test to see if it was reasonably well
supported to do this.

Mozilla: works
Opera: works
Safari/KTHML: works
IE6: doesn't work.

I thought it might be nice as kind of a namespace-ish feature on
elements generated by libraries, to make sure their IDs don't conflict.
But I'll have to use some other way I guess. Maybe they'll fix this
in IE7.

Jeremy
Aug 8 '06 #3
Jeremy wrote:
Mark Parnell wrote:
>Deciding to do something for the good of humanity, Jeremy
<je****@pinacol.comdeclared in comp.infosystems.www.authoring.html:
>>Is there some other way to specify this in CSS?
You could escape it, as with any other character:
strong#foo\:Bar
but what browser support will be like is questionable. Better to avoid
using it in the first place.
You're probably right. I ran a test to see if it was reasonably well
supported to do this.

Mozilla: works
Opera: works
Safari/KTHML: works
IE6: doesn't work.
HOWEVER: the other method of escaping--backslash followed by hexadecimal
representation--works in all of the above.

#foo\3a bar
or #foo\00003abar

Read http://www.w3.org/TR/CSS2/syndata.ht...ped-characters for an
explanation of the details, particularly for the special use of a space
to mark the end of the hex code unless a full six digits are used.
>
I thought it might be nice as kind of a namespace-ish feature on
elements generated by libraries, to make sure their IDs don't conflict.
But I'll have to use some other way I guess. Maybe they'll fix this in
IE7.

Jeremy
Aug 9 '06 #4
Harlan Messinger wrote:
>
HOWEVER: the other method of escaping--backslash followed by hexadecimal
representation--works in all of the above.

#foo\3a bar
or #foo\00003abar

Read http://www.w3.org/TR/CSS2/syndata.ht...ped-characters for an
explanation of the details, particularly for the special use of a space
to mark the end of the hex code unless a full six digits are used.
That's really interesting. I had never heard of that before. Thanks
for the tip!

Jeremy
Aug 9 '06 #5
Jeremy wrote:
Mozilla: works
Opera: works
Safari/KTHML: works
IE6: doesn't work.
Did you wrote that now, or is it just a standard .sig file for this
group? 8-)

Aug 9 '06 #6
On Wed, 09 Aug 2006 01:35:51 -0700, Andy Dingley wrote:
Jeremy wrote:
>Mozilla: works
Opera: works
Safari/KTHML: works
IE6: doesn't work.

Did you wrote that now, or is it just a standard .sig file for this
group? 8-)
rofl ... first chuckle of the day, thanks ;-)

Aug 9 '06 #7
Gazing into my crystal ball I observed Jeremy <je****@pinacol.comwriting
in news:mn9Cg.142$xB.80@fed1read10:
>
I thought it might be nice as kind of a namespace-ish feature on
elements generated by libraries, to make sure their IDs don't conflict.
I append a number to the id, eg:
<input type="radio" id="someid1" name="somename" value="r">Red
<input type="radio" id="someid2" name="somename" value="b">Blue
<input type="radio" id="someid3" name="somename" value="g">Green

--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share

Aug 9 '06 #8
Adrienne Boswell wrote:
Gazing into my crystal ball I observed Jeremy <je****@pinacol.comwriting
in news:mn9Cg.142$xB.80@fed1read10:
>I thought it might be nice as kind of a namespace-ish feature on
elements generated by libraries, to make sure their IDs don't conflict.

I append a number to the id, eg:
<input type="radio" id="someid1" name="somename" value="r">Red
<input type="radio" id="someid2" name="somename" value="b">Blue
<input type="radio" id="someid3" name="somename" value="g">Green
But if I use colons instead, like

<textarea id="My_Lib:post_content"></textarea>

When people look at the markup they'll think to themselves, "Wow!
Namespaced form elements! Now *this* guy has it together. What a pro!"

And that's all I really care about, anyway.

Kidding.... Seriously though, the colon does make a lot of sense as a
namespace specifier. Underscores are often used in database field
names, so given something like "My_Lib_post_content", it's ambiguous and
nontrivial to discover which part is the namespace and which part is the
field. What if I had another library called My_Lib_post which had a
field called Content? Those two elements, if on the same page, would
conflict.

Anyway, I'm clearly putting far too much thought into this :P

Jeremy
Aug 9 '06 #9
Jeremy wrote:
Kidding.... Seriously though, the colon does make a lot of sense as a
namespace specifier. Underscores are often used in database field
names
Use double-underscore as a namespace specifier then:

My_Lib__post_content

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

Aug 14 '06 #10

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

Similar topics

45
by: Edward K. Ream | last post by:
Hello all, First of all, my present state of mind re pep 318 is one of sheepish confusion. I suspect pep 318 will not affect Leo significantly, but I am most surprised that an apparently...
12
by: John | last post by:
I am currently using one of the IE hacks to give a PNG image full alpha transparency. But I wanted to move as much of this data to a .CSS as possible to lighten the load in the HTML as it is uses...
6
by: skeeterbug | last post by:
please check out http://www.geocities.com/operationsengineer1/test2.htm how come there is spacing between my logoheader and the tabs? i'm also seeing ie6 input an extra 1em of vertical...
7
by: Jonathan N. Little | last post by:
When doing a final check on my stylesheets the CSS Validator flag lines like this one as an error: ADDRESS A { color: gold; } Error is: # Line: 31 Context : ADDRESS A Invalid number :...
15
by: Davide R. | last post by:
Ciao a tutti, vi spiego il mio problema Ho una pagina HTML che referenzia un CSS esterno. Ho alcuni elementi HTML che appartengolo ad una classe (chiamiamola "class1"). Avrei la necessità,...
7
by: Wilhelm Kutting | last post by:
Hi again i want to replace the following layouttabel with css/xhtml: ---------------------------------- <table width="640" cellspacing="0"> <tr> <td valign="top">My Title</td> <td...
38
by: Arjang | last post by:
http://www.codeproject.com/useritems/CSharpVersusVB.asp
6
by: Grant Robertson | last post by:
I am relatively new to XML, though I have taught myself a lot in the past month. I keep seeing namespace names with multiple colons in them such as: "urn:oasis:names:tc:entity:xmlns:xml:catalog"...
26
by: machineghost | last post by:
First off, let me just say that as someone with no DBA training whatsoever, any help I can get with this issue will be very, very much appreciated. My company recently migrated our database from...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.