Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Use node # as CSS class names?

by joe++ (Friar)
on Dec 30, 2002 at 10:00 UTC ( [id://223011]=note: print w/replies, xml ) Need Help??


in reply to Re: (nrd) Use node # as CSS class names?
in thread Use node # as CSS class names?

Just one remark: I think you better use the CSS class rather than the id, because refs to one node can occur more than one time, and the ID attribute is supposed to be unique within one document (at least for well formed (x)html). This is also what adrianh suggested in his post.

Also, I'm not completely sure about CSS classes consisting of only numbers being legal, so we have:

...posted by <a href="...?node_id=186362" class="id186362">adrianh</a>...
And in your stylesheet:
.id186362 { background-color: orange; }
As for this idea being expensive at execution time, I hardly doubt so, as the node_id value should be known at page render time anyway for the href attribute; printing the same variable a second time should be rather trivial IMHO.

--
Cheers, Joe

Replies are listed 'Best First'.
Re^2: Use node # as CSS class names?
by adrianh (Chancellor) on Dec 30, 2002 at 11:21 UTC
    you better use the CSS class rather than the id,

    Quite correct.

    I'm not completely sure about CSS classes consisting of only numbers being legal

    Correct again :-) CSS identifiers (this covers both ID and class names) cannot start with a digit or hyphen. See the spec for the details.

    I lied. Underscores have been allowed since the 1998 errata.

    As for this idea being expensive at execution time, I hardly doubt so, as the node_id value should be known at page render time anyway for the href attribute

    I understood John's suggestion to mean that the class should only be applied to links to home nodes rather than to all links - and he was using the user name rather than the node ID. Knowing the difference between normal nodes and home nodes has got to cost something ;-)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://223011]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-25 00:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found