By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,766 Members | 1,265 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,766 IT Pros & Developers. It's quick & easy.

two, possibly off-topic, questions

P: n/a
Question 1:

Everyone here seems settled that the <div> tag is the place for an id
attribute and <span> tags are for class attributes. Why? It seems to me
that they are interchangeable. (Something about the aesthetics of the
whole thing wants to do away with <div> tags altogether and simply use
<span>. Is there some trap in doing this that I haven't found yet?)
Question 2:

I like the idea of inline frames. Hell, I may as well admit it, I like
frames [I hate when a menu scrolls off the screen because the doc I'm
viewing has to be scrolled through] but I do understand that they create
problems and I'm not going to argue this now. My question is that I have
one particular project where an <iframe> is REALLY helpful. Alas, only
Opera and Konqueror treat my code with respect. Both Mozilla and IE
refuse to replace my docs inside the frame and, instead, open a new
window. Is that simply the current state of support for <iframe> or are
there things that can get these others to play nice?

(The specific files I want to use contain copyrighted material which I'm
reluctant to put on the WWW, but if my description of this problem is
inadequate, I'll put some dummy files up to show you what I mean.)

Maury

--
http://www.his.com/~merkin
Jul 20 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
"Maury Merkin" <me****@his.com> wrote:
Everyone here seems settled that the <div> tag is the place for an id
attribute and <span> tags are for class attributes.
Have they? I see no evidence of that.
Why?
Maybe you're getting that impression beacause large divisions of a
page (marked up with <div>s) are more likely to be unique and hence
labelled with an id. Whilst short phrases (marked up with <span>s) are
more likely to occur more than once and thus should be labelled with
class.
<div id="navigation"> vs <span class="date">

But id and class can be applied to any element.
It seems to me hat they are interchangeable.
In HTML terms they are not. <div> is a block, <span> is inline; they
have different content models, etc.

Whilst they can be made to appear the same via CSS (i.e. display:
inline; for div or display: block; for span) that doesn't change they
structural nature.
(Something about the aesthetics of the
whole thing wants to do away with <div> tags altogether and simply use
<span>. Is there some trap in doing this that I haven't found yet?)
You can't nest paragraphs, tables, lists, headings, blockquotes, etc.
inside spans.
one particular project where an <iframe> is REALLY helpful. Alas, only
Opera and Konqueror treat my code with respect. Both Mozilla and IE
refuse to replace my docs inside the frame and, instead, open a new
window. Is that simply the current state of support for <iframe> or are
there things that can get these others to play nice?
How are you linking to the new document?
Is the link inside the iframe or in the parent page?
(The specific files I want to use contain copyrighted material which I'm
reluctant to put on the WWW, but if my description of this problem is
inadequate, I'll put some dummy files up to show you what I mean.)


Yes do so.

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net> <http://steve.pugh.net/>
Jul 20 '05 #2

P: n/a
Steve Pugh <st***@pugh.net> wrote:
"Maury Merkin" <me****@his.com> wrote:


re: <iframe> question
(The specific files I want to use contain copyrighted material which I'm
reluctant to put on the WWW, but if my description of this problem is
inadequate, I'll put some dummy files up to show you what I mean.)


Yes do so.


But do so in another newsgroup, it's not a stylesheet issue. I'd
suggest comp.infosystems.www.authoring.html

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net> <http://steve.pugh.net/>
Jul 20 '05 #3

P: n/a
On Sun, 06 Jun 2004 11:35:39 -0400, Maury Merkin <me****@his.com> wrote:
Question 1:

Everyone here seems settled that the <div> tag is the place for an id
attribute and <span> tags are for class attributes.


Where is "here"? On this newsgroup, it's understood that id and class are
used more appropriately than that. If you mean a different "here", I
assure you "they" are wrong.
Jul 20 '05 #4

P: n/a
"Maury Merkin" <me****@his.com> wrote in
comp.infosystems.www.authoring.stylesheets:
Everyone here seems settled that the <div> tag is the place for an id
attribute and <span> tags are for class attributes.


Huh? I don't know where "here" is, but I've never observed any such
consensus.

id attributes must be unique within page; a class can be used many
times on a page. That's kind of irrelevant to using div or span
tags.

--
Stan Brown, Oak Road Systems, Cortland County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2 spec: http://www.w3.org/TR/REC-CSS2/
2.1 changes: http://www.w3.org/TR/CSS21/changes.html
validator: http://jigsaw.w3.org/css-validator/
Jul 20 '05 #5

P: n/a
"Maury Merkin" <me****@his.com> wrote:
Question 1:

Everyone here seems settled that the <div> tag is the place for an id
attribute and <span> tags are for class attributes.
The id attribute is a unique identifier, used to name a single element
on a page. (This isn't merely a custom or common practice, it's a rule
of HTML. Using the same id value twice on one page results in an
invalid page.) Applying a style to the element that has a particular
id is only one of the uses of the id attribute. Other uses include
setting destinations for internal document links and DOM manipulation
by script.

The class attribute is to indicate that any number of elements are
intended to share some set of characteristics, typically a set of
styles. For example, you might have classes for names of species
(recalling a discussion held here several months ago), links to
entries in your web site's glossary (as distinct from links to any
other page), footnotes, lines of poetry, and so on.

If you use DIVs to divide your page up into its principal components,
then, yes, each DIV will probably have a distinctive function that
would be best reflected in a unique ID: "banner", "leftnav", "topnav",
"footer", "sidebar", "maincontent". These are things of which the page
has one each. So it makes sense that *these* DIVs would have id
attributes, which would be used to apply styles specific to one or
another of them. But if, say, you have a lot of photographs on your
page, each with information related to it in a particular format, then
you might want to wrap a DIV around each photo with its info, and
format all these DIVs the same way. That would call for a class rather
than an ID.

There isn't generally any reason why a non-block element on a page
would warrant having a style assigned to it based on a unique ID, even
if it has one. So for spans, styles will most likely be associated
with them based on classes (like "species", "glossarylink", "poetry",
"footnote", and so forth)..
Why? It seems to me
that they are interchangeable. (Something about the aesthetics of the
whole thing wants to do away with <div> tags altogether and simply use
<span>. Is there some trap in doing this that I haven't found yet?)


DIVs are blocks and SPANs are inline. Yes, you can change that with
CSS, but speaking in terms of document structure, a DIV is, a full
division of the page, if you think of a page being broken up into
blocks. A span is not necessarily an integral component of anything.
--
Harlan Messinger
Remove the first dot from my e-mail address.
Veuillez ôter le premier point de mon adresse de courriel.
Jul 20 '05 #6

P: n/a
Maury Merkin wrote:
Question 1:

<snip>Question about using <div> and <span> with ids and classes.</snip>
Question 2:

<snip>Question about <iframe></snip>
Then why on earth did you post them to c.i.w.a.stylesheets? They're
clearly HTML questions, which should be directed at c.i.w.a.html, where
they would actually be two, possibly /on-topic/, questions.
(The specific files I want to use contain copyrighted material which
I'm reluctant to put on the WWW, but if my description of this problem
is inadequate, I'll put some dummy files up to show you what I mean.)


When you're experiencing a problem with some code, it is always
preferable to upload some files to a server somewhere and give a URI.
Or, at a minimum, provide a small snippet of sample code, so that
someone may see where you're error is; however this is *not* useful for
full HTML files, where we would need to copy the code and make a new
file to test it — it's too time consuming. Also, validating you're code
first always helps, and may infact solve you're problem without needing
to ask.

--
Lachlan Hunt
http://www.lachy.id.au/
la**********@lachy.id.au.update.virus.scanners

Remove .update.virus.scanners to email me,
NO SPAM and NO VIRUSES!!!
Jul 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.