This is a discussion on "Help understanding DIV" within the Web Page Design section. This forum, and the thread "Help understanding DIV are both part of the Design Your Website category.
|
|
|
|
|
![]() |
||
Help understanding DIV
|
||
| Notices |
![]() |
|
|
LinkBack (1) | Thread Tools |
|
|||
|
Help understanding DIV
i have a question. I need help understanding DIVs better. I thought i knew about them but now i know i dont. So i eget the div but what is the diffrence between these to code lines. <div id="footer"> or <div class="footer"> and how would each one be used and what would it look like in the style sheet
Last Blog Entry: Website critique (Apr 16th, 2008)
|
|
|
|
||||
|
Re: Help understanding DIV
Well in the stylesheet an id would be referanced with a '#' so for example:
|
|
|||
|
Re: Help understanding DIV
so what would you use each one for?
Last Blog Entry: Website critique (Apr 16th, 2008)
|
|
||||
|
Re: Help understanding DIV
You can use an ID for whatever you want BUT you must only use it ONCE. You can use a class as much as you wish.
Please note you can use an ID as many times as you want as long as it isnt the same one e.g. id="footer" and id="footer". Normally i use an ID for like a containing div, a header div and a navigation div (things that are only going to be used once on a page!). Hopefully that clarifys this for you |
|
|||
|
Re: Help understanding DIV
i think so thanks
Last Blog Entry: Website critique (Apr 16th, 2008)
|
|
||||
|
Re: Help understanding DIV
Usually ID are used for your main sections (for a lack of a better word right now) like: branding (header), navigation, content, site info (footer)
Other stuff like: thumbnails or advertising, etc.... I would use classes. hth |
|
||||
|
Re: Help understanding DIV
IDs are also used in JavaScript to select an element with a particular ID. This is very useful!
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
|||
|
Re: Help understanding DIV
Generally I use id's for structural areas that you know will not be replicated on the page.
Last edited by JacobHaug; Oct 8th, 2007 at 16:25. Reason: No signature for at least 10 posts! |
|
||||
|
Re: Help understanding DIV
The below is from smashing magazine
2.1. Technical Tips: IDs, Classes
__________________
WelshStew Lead Administrator tierney rides tboard - uk site | xtreme wales - extreme clothing If you think I've helped, click the "Thanks" webforumz - facebook | LinkedIn
Last Blog Entry: Web Standards Curriculum Launched (Jul 8th, 2008)
|
|
||||
|
Re: Help understanding DIV
To keep it simple:
use ID's for layout and Classes for elements that may need more than a single instance on any page.
Last Blog Entry: Apps every Mac based web dev should consider (Jul 10th, 2008)
|
|
||||
|
Re: Help understanding DIV
I didn't know you could use more than one class on an element, thanks Welshstew
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
|||
|
Re: Help understanding DIV
Something you may also find handy is you can add multiple classes to tags, so lets say you want a highlight (a different color) and want to increase the font size on the first sentence of a paragraph.
This can be done by having a separate class for the font size up, and the highlight in case you want to reuse the elements for other things also, but don't want them combined together, if that makes sense, hope this helps some people realise you can add as many classes as you like to a tag. Example:
So in short, multiple classes will come in handy sooner or later. |
![]() |
| Thread Tools | |
|
|
LinkBacks (?)
LinkBack to this Thread: http://www.webforumz.com/web-page-design/60699-help-understanding-div.htm
|
||||
| Posted By | For | Type | Date | |
| 70 Expert Ideas For Better CSS Coding | CSS | Smashing Magazine | This thread | Refback | May 8th, 2008 03:12 | |
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help with understanding DOCTYPES in Dreamweaver! | bellabella | Web Page Design | 1 | May 16th, 2008 22:42 |
| A little understanding would be useful (Flash, .flv and Websites) | Phil | Flash & Multimedia Forum | 9 | Sep 4th, 2007 15:41 |
| Difficulty understanding Contact Form | henryd | Introduce Yourself | 3 | Oct 8th, 2005 02:53 |
| Hi Everone New to this so be understanding! Will post | geoffg | Introduce Yourself | 6 | Sep 21st, 2004 22:24 |