[UPHPU] More CSS frustration
Brandon Stout
bms at mscis.org
Wed Jan 17 22:37:36 MST 2007
cole at colejoplin.com wrote:
> I've not seen an established guideline. Has anyone else? Myself, as a
> long-time programmer, I'm conditioned for reusing functions and
> objects, and leveraging inheritance. CSS classes imply reuse multiple
> times on a page, while ids are unique to a page. By default, I use
> classes, enabling reuse, and when I absolutely need uniqueness, I use
> ids.
>
> For example, I created a 3-tier menu once, that expanded and
> collapsed, using javascript and nested <ul>s, where I had both general
> classes and specific ids. I needed uniqueness for changing the visible
> properties of the divs. I use inheritance to leverage properties in
> parent divs to control child divs.
>
> I hope that answers your questions okay.
>
> -- Cole
First, sorry for the duplicate Cole, used "Reply" instead of "Reply-All"
that time...
While I also have not seen an established guideline, I agree. I use
classes as Cole does. I also use ids frequently, but not usually for
CSS layout. Instead, I use ids for finding a specific section. For
example, say I have a 10 page article (10 html pages), and I have a link
to view the whole article as one page MySQL does this for their
documentation). In the page-view, I have navigation links for the
separate pages. In the one-page-view, I have navigation links as well,
but they jump to the part of the single-page with the content desired
via the id attribute. One no longer needs to <a
name="uniqueName"></a>Targeted Text, one can simply add an attribute to
the element containing the target text.
IOW: I use the id element for (enter drumroll ...) identification, and I
use the class element for css. Occasionally, I'll add CSS to an ID, but
only if I want that one element to stand out; e.g.: I might want the
main menu to look different from all other menus. If I do, I'll CSS the
main menu's ID.
Brandon Stout
http://mscis.org
More information about the UPHPU
mailing list