HighDots Forums  

Really stupid newb question- <div>

alt.html alt.html


Discuss Really stupid newb question- <div> in the alt.html forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Jeremy Brown
 
Posts: n/a

Default Really stupid newb question- <div> - 06-05-2006 , 04:31 AM






OK, I see the <div> tag referred to allot- What exactly does it do and what
is its usage? Please forgive my tresspass...

Jeremy

--
Visit my Saab & me at:
http://jerem43.home.att.net




Reply With Quote
  #2  
Old   
ironcorona
 
Posts: n/a

Default Re: Really stupid newb question- <div> - 06-05-2006 , 05:47 AM






Jeremy Brown wrote:
Quote:
OK, I see the <div> tag referred to allot- What exactly does it do and what
is its usage? Please forgive my tresspass...
It's not a stupid question. You just don't know.

Try this:
http://www.w3.org/TR/REC-html40/stru....html#edef-DIV

div is just a generic block element that can be used to separate
different structural sections of the page. It doesn't do anything
presentational to the page. It's quite possible [but inadvisable] to
create an entire web page with just <div> and <span> in the <body>.

--
Brian O'Connor (ironcorona)


Reply With Quote
  #3  
Old   
Andy Dingley
 
Posts: n/a

Default Re: Really stupid newb question- <div> - 06-05-2006 , 05:57 AM




Jeremy Brown wrote:
Quote:
OK, I see the <div> tag referred to allot- What exactly does it do and what
is its usage?
What does it do? - Not a lot.
What can it do? - A great deal.

It's there as a deliberately anonymous way of structuring your content.
It adds little implicit behaviour (i.e. your browser will barely show
you a difference) but it lets you hook lots of new behaviours onto it,
typically through CSS.

<div> has a closely related element called <span>. They're used in
similar ways, but <div> is a block-level element and <span> is inline
(*). In HTML this means you can put <span> inside <div>, but you
CANNOT put <div> inside <span>. Similarly for other block level
elements like <p> or inlines like <b>. <div> offers a bit extra
though, in that you can put <div> or <p> inside a <div>, even though
you couldn't put either inside <p>. You can't change any of this
stuff - you're stuck with it.

<div> also has some CSS behaviours attached to it. These have implicit
values (in the browser), but you can (and will) easily change them by
writing your own stylesheets. In particular, <div> has the
"display:block;" declaration and <span> has "display:inline;" This
makes <div> render on your page with linebreaks around it, but <span>
flows with the text. These values are usually adequate, but they're
easily changed. Typically you make <div> display:inline; so that you
can have valid HTML that looks like inline text, even though it has
HTML content in it that couldn't be placed into a <span>.

By using the <div class="..." > attribute, you can attach CSS to
specific <div>s on a page. This is how you control presentation and
layout these days.

You _could_ write a whole HTML page using little more than <div> and
CSS. It would even look good. But this wouldn't be a good idea. If you
have "a paragraph" according to the rules of language and grammar, then
still mark it up as <p>. Use <div> when you need to define blocks of
content (for any reason) and they don't fit a more specific HTML
element type (and you can't use <span> instead)

There's also an id attribute that you can attach to elements. This is
mainly used for JavaScript, as a way of "finding" blocks on a page so
that they can either be read or modified. You can also use id to hang
your CSS onto, a bit like class.


(*) Strictly HTML doesn't have such an idea as "block level elements".
It describes this in two separate ways, "Where you can use this
element" and "What else you can put into this element". Generally
though these two are the same and we can talk about "a block element"
or "an inline element". To understand this fully you'll need to learn
about concepts like "DTD" and "validity" -- search this newsgroup, or
c.i.w.a.h

I've also simplified many of the technical details of HTML, so as to
fit an introduction into this short post. Bean counters can sod off!



Reply With Quote
  #4  
Old   
mbstevens
 
Posts: n/a

Default Re: Really stupid newb question- <div> - 06-05-2006 , 08:39 AM



Jeremy Brown wrote:
Quote:
OK, I see the <div> tag referred to allot- What exactly does it do and what
is its usage? Please forgive my tresspass...
It is a generic block element that is often overused ("divitis") by
people who forget that their other block elements can be styled with CSS
just as easily as a div. You often see things like

<div>
<ul>
<li>........
<ul>
</div>

with the div instead of the ul styled when

<ul>
<li>........
</ul>

would do.


Reply With Quote
  #5  
Old   
Jeremy Brown
 
Posts: n/a

Default Re: Really stupid newb question- <div> - 06-05-2006 , 10:19 AM



OK, I think I understand. Would this be right?

I have a "compass rose" on each of my pages that moves you around on the
page (top or bottom) or site (previous or next page). To keep the "rose"
separate from the preceding and upcoming sections, I have an empty <p></p>
before the table that creates the "rose".

here is what it looks like:
http://jerem43.home.att.net/pages/9x.html

here is the HTML (truncated for brevity):

<!--Navigation-->
<p>
</p>

<table class="navbox">
<!--blah, blah, blah yackety-schmackety goes here-->
</table>
<!--End Navigation-->

Would this do the same thing, and is it the correct usage?

<!--Navigation-->
<div>

<table class="navbox">
<!--blah, blah, blah yackety-schmackety goes here-->
</table>

</div>
<!--End Navigation-->

I am guessing that I could create a class that would define how far away the
"rose" would appear from the various surrounding elements to further help
structure the page.

Jeremy
--
Visit my Saab & me at:
http://jerem43.home.att.net


Quote:
OK, I see the <div> tag referred to allot- What exactly does it do and
what is its usage? Please forgive my tresspass...

Jeremy



Reply With Quote
  #6  
Old   
verity
 
Posts: n/a

Default Re: Really stupid newb question- <div> - 06-05-2006 , 11:14 AM




Jeremy Brown wrote:
Quote:
OK, I see the <div> tag referred to allot- What exactly does it do and what
is its usage? Please forgive my tresspass...

Jeremy

--
Visit my Saab & me at:
http://jerem43.home.att.net
Good question, I didn't know that & now by reasding answers to your
post, I do

BTW like the cats & dog.



Reply With Quote
  #7  
Old   
Andy Dingley
 
Posts: n/a

Default Re: Really stupid newb question- <div> - 06-05-2006 , 12:31 PM



Jeremy Brown wrote:

Quote:
I have a "compass rose" on each of my pages that moves you around on the
page (top or bottom) or site (previous or next page). To keep the "rose"
separate from the preceding and upcoming sections, I have an empty <p></p
before the table that creates the "rose".

p
/p
This is (almost) never a good idea. It's the web equivalent of the old
DTP tricks for spacing things out by putting empty whitespace elements
everywhere.

If you want [A} and [C] to be presented with some white space between
them, then use CSS and bigger margins (probably margin-top on [C]) to
set it. Don't create a [b] element just to sit between them - it's
just not needed.


Quote:
table class="navbox"
I doubt you need to, nor should, use a table here -- but that's a
separate issue.

Quote:
div
table class="navbox"
This would probably have no effect at all.

Now it's possible that this is what you needed instead
<div class="navbox">
<table>

but in general, without having actually looked at your page, then you
can probably do it perfectly well like this
<table class="navbox">

<table> is already a block element and you have a class attribute on it
so you can attach most CSS that you might want. Unless you're doing
something paticularly complex, that's probably all the HTML you need.



In general, your markup wants an overall make-over. It's pretty much
1997 style, only in XHTML.

Lose the frames.
Lose the HTML 3.2 coding style.
Lose the Transitional doctype.
Lose the <table>s
Lose the rainbow bullets.
Lose the frames.

The XHTML is OK, although many people will proceed to tell you it's
wrong. It's not helping much, but it doesn't actually hurt.



Reply With Quote
  #8  
Old   
Jeremy Brown
 
Posts: n/a

Default Re: Really stupid newb question- <div> - 06-05-2006 , 01:16 PM



Just an informational response:

Quote:
This is (almost) never a good idea. It's the web equivalent of the old
DTP tricks for spacing things out by putting empty whitespace elements
everywhere.
That is why I wish to do. I have eliminated a ton of older styles in the
markup. I have elimanted almost all of the depreciated tags on all of the
pages on my site. I have switched just about all formatting to my style
sheet.

Quote:
If you want [A} and [C] to be presented with some white space between
them, then use CSS and bigger margins (probably margin-top on [C]) to
set it. Don't create a [b] element just to sit between them - it's
just not needed.
This is the kind of information I need. Sometimes the simple solution often
eludes us. I honestly would not have thought to use the margin functions in
my CSS since I am still learning how to utilize it to its full potential.

Quote:
I doubt you need to, nor should, use a table here -- but that's a separate
issue.
The artwork is 5 separate elements, not one. I know you can do that using a
single image with coordinate mapping and there are other ways, but that is
not how I wish to do so. The table works rather well in doing what I wish to
do.

Quote:
In general, your markup wants an overall make-over. It's pretty much
1997 style, only in XHTML.

Lose the frames.
Lose the HTML 3.2 coding style.
Lose the Transitional doctype.
Lose the <table>s
Lose the rainbow bullets.
Lose the frames.

The XHTML is OK, although many people will proceed to tell you it's wrong.
1. I am going to dump the frames as soon as I learn how to layout the site
fully in CSS. (see #3)
2. Please read my home page in regards to my HTML skills- I am still
learning how to do it, hence it isn't beautifully typed up. I am typing all
of this out in Notepad, and the way I type lets me read it and know what I
looking at while I work on it.
3. I actually have a version of my site that is Strict, but it does not look
the way I want it to yet. (see #1)
4. The frames do what I want, they validate in Transitional & Strict and I
like the look.
5. How I design may page is not really the point here, I simply want to
learn HTML and have some fun doing so. I like the way my site looks. It is
amateurish because that what it is- an amateur HTML coder presenting his
amateur automotive skills on a personal web page. I am sure that some time
in the future I will bring the site into the 21st century, maybe 2002 or
2003, until then the layout stays- rainbow icons and all.
6. See #1 & #3

All this said, why did you need to critique my whole site when I only asked
a question about an XHTML tag?

Jeremy


--
Visit my Saab & me at:
http://jerem43.home.att.net




Reply With Quote
  #9  
Old   
Jeremy Brown
 
Posts: n/a

Default Re: Really stupid newb question- <div> - 06-05-2006 , 01:43 PM



Number four should read :

4. The tables do what I want, they validate in Transitional & Strict and I
like the look.

Quote:
1. I am going to dump the frames as soon as I learn how to layout the site
fully in CSS. (see #3)
2. Please read my home page in regards to my HTML skills- I am still
learning how to do it, hence it isn't beautifully typed up. I am typing
all of this out in Notepad, and the way I type lets me read it and know
what I looking at while I work on it.
3. I actually have a version of my site that is Strict, but it does not
look the way I want it to yet. (see #1)
4. The frames do what I want, they validate in Transitional & Strict and I
like the look.
5. How I design may page is not really the point here, I simply want to
learn HTML and have some fun doing so. I like the way my site looks. It is
amateurish because that what it is- an amateur HTML coder presenting his
amateur automotive skills on a personal web page. I am sure that some time
in the future I will bring the site into the 21st century, maybe 2002 or
2003, until then the layout stays- rainbow icons and all.
6. See #1 & #3



Reply With Quote
  #10  
Old   
Andy Dingley
 
Posts: n/a

Default Re: Really stupid newb question- <div> - 06-05-2006 , 03:56 PM



On Mon, 05 Jun 2006 17:16:57 GMT, "Jeremy Brown" <jerem43 (AT) att (DOT) net>
wrote:

Quote:
All this said, why did you need to critique my whole site when I only asked
a question about an XHTML tag?
No problem, I see no reason to ever visit your site
or read any of your postings ever again.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.