Loading...
 
Skip to main content

Themes


You are viewing a reply to Inserting image full width top area

Re: Inserting image full width top area

Japan

If you have a div (essentially a container), you can give it a class or an id or both. In the related CSS rules, div.middle refers to a div whose class is "middle", and div#middle refers to a div whose id is "middle"; "div.middle" can be written as ".middle" if there aren't any other page elements with the class "middle". If there are (like div.middle, ul.middle, etc.), then ".middle" would refer to all of them, which you may not want (although you might, depending on the situation).

A CSS class is used when there might be multiple instances of it and you want the rules to apply to all of them, such as Tiki's modules, which all have a "module" class. There can be only one id with a particular name on a page (so only one "div#middle" is permitted on a page, for example) for the HTML to be valid.

The best practice is to assign styling rules to classes rather than to ids, because a rule given to an id is so strong it's hard to make exceptions to that rule within the id (so if there's a div class="middle" id="middle", any style rules should be assigned to .middle, and #middle should instead be used for JavaScript use, navigation anchors, etc.

In stylesheets, the syntax is div.middle and div#middle (or .middle and #middle). In HTML, the syntax is div class="middle" and div id="middle".

-- Gary