Click to See Complete Forum and Search --> : custom selectors ?


dmaher
11-19-2009, 09:53 PM
Hi, sorry for the newbie question, I'm new to all this but having a go.

What I'm trying to achieve is extremely simple, essentially I just want a part of some text in the footer a certain colour. I thought acc, for accent might be a reasonable name for it.

I tried this:

acc{color: #6600FF; clear:both;}

and then in my footer.php,

A <acc>quick</acc> brown fox jumps over the lazy dog.

Now that works in FF, however the validator didn't really like it. It said acc not defined.

So I changed it to a class so:

.acc{color: #6600FF; clear:both;}

and

A <span class="acc">quick</span> brown fox jumps over the lazy dog.

That also works and the validator seems okay with it, which is all good.

However it got me wondering, can you not have 'custom' selectors similar to say p or h1 etc. and I have to make it a class and use the span tags every time ?

ssystems
11-19-2009, 10:18 PM
Yes you can. Create a custom DTD and use it as your doctype. However, this SHOULDN'T be done. If you've been in the industry long enough you'll recall that the one of the objectives why the W3C was formed was to avoid just anyone creating their own elements (standardization). Your the only one that knows the meaning of your element.

dmaher
11-19-2009, 10:22 PM
Yes you can. Create a custom DTD and use it as your doctype. However, this SHOULDN'T be done. If you've been in the industry long enough you'll recall that the one of the objectives why the W3C was formed was to avoid just anyone creating their own elements (standardization). Your the only one that knows the meaning of your element.

So best practice is to use the span tags ?

ssystems
11-19-2009, 10:23 PM
So best practice is to use the span tags ?

Yes.

dmaher
11-23-2009, 05:30 AM
Thanks for your help. Haven't exactly been in the industry... my qualifications are in comms cabling. ;)

Charles
11-23-2009, 08:43 AM
But before you use the SPAN tag, ask your self "What am I trying to say?" Chances are that if you are trying to make some text stand out then you are trying to emphasize that text then you should use EM of STRONG. Only use SPAN as a last resort and then give it a class with a name that describes why you are setting that text apart.

http://www.w3.org/TR/html4/struct/text.html#h-9.2.1

dmaher
11-24-2009, 02:31 AM
It's to apply a certain colour to words, in line with one of the main colours used on the site to make them stand out. So I would like any changes to that colour reflected across the site, if the colour scheme is changed or altered slightly.

Isn't strong more akin to bold ?

Fang
11-24-2009, 03:34 AM
It's a question of how much emphasis is required (http://www.cs.tut.fi/~jkorpela/html/em.html).