Posts Tagged ‘specificity’

Web Designing-Eliminate element types for class and id selectors

Wednesday, July 16th, 2008

When writing selectors that target an element with a certain class or id value, you can omit the element type before the . (class selector) or # (id selector).

So, instead of writing

1. div#content { /* declarations */ }
2. fieldset.details { /* declarations */ }

you can write

1. #content { /* declarations */ }
2. .details { /* declarations */ }

and save a few bytes for each selector.

This is especially useful for id selectors since they must be unique in a document, which reduces the risk of rules conflicting with each other. class names on the other hand can be used any number of times in a document, and different element types can be assigned the same class name (or names). To style element types with the same class name differently you will need to specify the element types in the selector.

Be aware that the above rules are not identical. If you write one rule with and one rule without the element type in the selector, the rule that uses the element type will have higher specificity.

Participate at Related Forums & Blogs

Thursday, June 19th, 2008

Whatever industry or niche you’re in, there are bloggers, forums and an online community that’s already active. Depending on the specificity of your focus, you may need to think one or two levels broader than your own content to find a large community, but with the size of the participatory web today, even the highly specialized content areas receive attention. A great way to find out who these people are is to use Technorati to conduct searches, then sort by number of links (authority). Del.icio.us tags are also very useful in this process, as are straight searches at the engines (Ask.com’s blog search in particular is of very good quality).