[rt-users] maintainably tagging custom fields for CSS

Espen Wiborg espenhw at ovitas.no
Thu Aug 16 03:18:05 EDT 2007


Nicholas Clark <nick at ccl4.org> writes:
> Jesse, on IRC, has the alternative suggestion of using a class. It has the
> advantage that it won't be invalid XML if two fields happen to end up with
> the same ID. But what's going to be impractical in class names for CSS?
>
> I did this to map & and "
<-snip->
> But my HTML can be:
>
> <tr id="CF-9-EditRow" class="What next">
>
> Is that space in the class name going to be a problem?
>
> What's a sensible restriction on what can go in? Is there a CSS grammar for
> what is(n't) valid in a class name?

You can find the formal syntax and grammar for CSS2 here:
http://www.w3.org/TR/REC-CSS2/grammar.html

>From that definition and the examples given in
http://www.w3.org/TR/REC-CSS2/syndata.html, you can do things like:

tr[class="What next"] { color: blue; }

So spaces won't be a problem.

On the gripping hand, having spaces in a class name means that things
like

tr.next { color: black; }

will match if one of the (whitespace-separated) tokens in the class
attribute is 'next' (see the definition of the ~= operator in section
5.8.1 of http://www.w3.org/TR/REC-CSS2/selector.html - foo.bar is
actually shorthand for foo[class~="bar"]).

I'd actually like a lot of information about the CF to somehow be
encoded in the class attribute:

Scope (ticket, transaction, user, group)
Type (single/multi value, single/multi select etc)
Validation (especially if mandatory)

To make this easy (or even possible), it seems you'd almost have to
strip spaces from the CF name.

(
As an aside: Unicode escapes (e.g., "\002264" for the
greater-than-or-equal sign) mean that unicode class names wouldn't be a
problem either.  :)

Of course, there is always the question of browser support.  I've never
actually had to use this in the wild, so I don't know what browsers will
actually do with a specification like:

tr[class="\0003b1\0003b2\0003b3\0003b4"] { color: magenta; }

(That's greek lowercase letters alpha, beta, gamma and delta).
)

-- 
Espen Wiborg <espenhw at ovitas.no>
The giant squid has the largest eyes in the world.



More information about the rt-users mailing list