OZONE Asylum
Forums
XML - XSL - XSLT - XHTML - CSS - DOM
some questions on css
This page's ID:
10773
Search
QuickChanges
Forums
FAQ
Archives
Register
Edit Post
Who can edit a post?
The poster and administrators may edit a post. The poster can only edit it for a short while after the initial post.
Your User Name:
Your Password:
Login Options:
Remember Me On This Computer
Your Text:
Insert Slimies »
Insert UBB Code »
Close
Last Tag
|
All Tags
UBB Help
I'll take #'s 1 & 2. you are on the right track when you say the . refers to classes and the # refers to ids. Now, what is the difference? The difference is in how you use them within your html. Let us say you have a div that you would like to have positioned in a certain place. Well, since you wish to define the style of that 1 div, you would use the id. html = <div id='somethingSpecial'>;sdfjsdlf;sj</div> css = #somethingSpecial{position:absolute; top:10px; left:25px;} Of course you could go on to define all sorts of things about that div: background color or image, margins, paddings, borders, etc. ... even define the fonts inside that div with font-family, font-size, color, line-height, etc. Now, on to classes. classes are used when you wish to define a style that will apply to many elements on your page. an example would be...let's say you had a page you wanted 2 columns. One column that would hold content, on the right side of the page, and a series of divs that would hold auxiliary stuff (nav, links, sidenotes, whatever) on the left side of the page. All the divs in that second column (the one on the left) could be given a class and then you define that in the style sheet one time so all divs with that class have the same style. html = <div id='nav' class = 'auxillary'>;aldfjdsljfsd</div> <div id='links' class = 'auxillary'>;aldfjdsljfsd</div> <div id='sidenote' class = 'auxillary'>;aldfjdsljfsd</div> <div id='whatever' class = 'auxillary'>;aldfjdsljfsd</div> css = .auxillary{float:left; clear:left; width:40%} ...and so on. Like using the id's, you may define all sorts of styles to a class of elements -- positioning, padding, margins, borders, background colors and images, fonts, etc. So, in short, use id to define styles that will apply to only one very specific element (whether that element is a div, span, anchor, table, paragraph...whatever) and use class to define styles that will apply to a collection of elements. Another thing is, you can define style for a particular type of element. css = p{font-family:verdana; font-size:10px; color:#4a4a4a;} (Notice there is no punctuation in front of the 'p') That style will apply to all paragraphs in your html, unless you later specifically override this with a class or an id style. You can do that with any type of element (div, span, anchor, table, headings, etc.) Cool? mobrul [edit:damn, pugz is too fast!] [This message has been edited by mobrul (edited 07-18-2002).]
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »