[TYPO3-dev] which naming scheme for a CSS XHTML id

Christopher bedlamhotel at gmail.com
Thu Jun 8 16:37:02 CEST 2006


Hi Franz,

On 6/8/06, Franz Holzinger <franz at fholzinger.com> wrote:
> Hello,
>
> Robert Markula currently wants to improve tt_products with ids for
> generating a CSS styled shop template.
>
> <INPUT size="8" maxlength="10" type="text" name="###FIELD_NAME###"
> value="###FIELD_QTY###" id="###FIELD_ID###">
>
> So I propose to use these example ids:
>
> tt_products_list_id_01
>
> tt_products_listhighlights_id_01
>
> tt_products_basket_id_01
>
> tt_products_single_id_01
>
> Each product/article will get another number at the end. The middle part
> contains the code field which can have been generated internally from
> the activity parameter.
>
> Just tell me now if I should follow another naming scheme for ids.


Can you provide a little bit more information about how the ids will
be used? It's hard to suggest a best practice without knowing a little
more about what you're trying to achieve. Will the ids be used just on
form controls for accessibility reasons? Or is the intent to use them
on many elements for css styling?

In your code snippet above, for example, I don't exactly see the point
of an id attribute if the purpose is to use it to style the element.
That is, it's not clear to me why you would  want to style many small
elements with ids because:

a) they can likely be styled already using plain html selectors or
descendent selectors:

.tt_products ul { /* styles */ }

b) or, in the case of input elements (since IE can't understand
attribute selectors [1]), a class attribute:

.tt_products .inputText { /* styles for <input type="text"
class="inputText" ... /> */ }

Using either of the above methods generally makes stylesheet
maintenance much easier than having multiple id declarations (even if
they're grouped) in the stylesheet, and would probably result in the
extension template's markup being less 'opinonated' about the eventual
layout.

Two things do occur to me though:

1. Any given record already _has_ a uniqe id in the database, so why
not use that number in any required ids instead of a new numbering
system?

2. It may be worthwhile to make the id format TS-configurable


-Christopher



[1] http://www.webmasterworld.com/rd.cgi?f=83&d=7462&url=http://www.w3.org/TR/CSS21/selector.html#attribute-selectors




More information about the TYPO3-dev mailing list