Topic: Correct HTML Structure Questions (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=28318" title="Pages that link to Topic: Correct HTML Structure Questions (Page 1 of 1)" rel="nofollow" >Topic: Correct HTML Structure Questions <span class="small">(Page 1 of 1)</span>\

 
H][RO
Paranoid (IV) Inmate

From: Australia
Insane since: Oct 2002

posted posted 08-10-2006 04:09

Just a few Q's that i should know, but for some reason have uncertainties about!

1. Is it legal to put tables within paragraph tags, and is it legal to put paragraph tags within TD tags.

2. Where exactly should form tags go, i assume the best places are outside elements such as paragraphs and tables, but inside DIVs

3. Is it legal to put lists, UL, OL within paragraph tags or are they meant to fly solo. You can put them within tables obviously so i would assume its legal in paragraphs too.



I tend to put lists and tables within paragraph tags because they inherit the paragraph text styles, but i dont know if this is correct? (never seen any problems... but.. you know.)

Considering you put images, links etc within a paragraph - i would assume its legal, and semantically correct. Tables in their proper use are comparable data to images etc i would have thought.

JKMabry
Maniac (V) Inmate

From: raht cheah
Insane since: Aug 2000

posted posted 08-10-2006 05:03

as for the legality of the things you're asking about, just try validating, that's the Law/Standard for legality

The rest is down to the semantic meaning of the markup, I'd think you could conceivably end up with some type of tabular data that needs to be in paragraph tags, but I'd think it highly unlikely and very strange circumstance that would require it to provide meaning to the markup (and that's what you're after with your markup). Lists in paragraphs can be fine, I can list things in a paraggrahp while talking or writing so yes... but it sounds like you are just trying to use the paragraph to determine the styling by just wrapping it, and that goes against the point of semantic markup and seperate styling.

The C in CSS stands for cascading so start with some generic style decalration to the body element then everything under it in the cascade will inherit, then tweak child elements as needed.

In none of your examples does the paragraph tag seem required or wanted as they are not defining a paragraph in any

DL-44
Lunatic (VI) Inmate

From: under the bed
Insane since: Feb 2000

posted posted 08-10-2006 05:07

One easy way to find out: run it through the validator!

Forms can be done in a variety of ways. They can be within a div, but they don't need to have a container - they can stand on their own.

In some contexts a table is a appropriate to hold a form, but I would reserve this for particularly complex forms where the standard label/input setup becomes inadequate.

I would not put a form in a paragraph. I do not know if it is allowed, but it does not belong within a paragraph.

I Would also not put a table in a paragraph, and usually would not put an image in a paragraph either. I am unsure whether it is "allowed" but it is not semantically proper IMO. It really shouldn't be inheriting styles from a paragraph in the first place - the paragraph should be inheriting styles based on its parent, and any other styles that are necessary for the table should be specified in relation to the same parent.

I am unsure where lists are/are not allowed. usually there is no purpose for putting them within a paragraph, and it seems semantically incorrect as well. Paragraph ends, list begins. List ends, next paragraph begins. Common structure for documents...

Again - anytime you are unsure what is "allowed", make sure you've got a proper doctype (afterall, your doctype determines what is allowed and what isn't), and run it through a validator.


{{edit - damn, beat to the punch

(Edited by DL-44 on 08-10-2006 05:08)

H][RO
Paranoid (IV) Inmate

From: Australia
Insane since: Oct 2002

posted posted 08-10-2006 07:12

Yeah thanks, good points.

Actually in the frontend of the websites i dont normally have the paragraph tags outside of anything, except images, links, form elements (not the form tag).

Admittedly i do cheat a bit in my back end content management system and use paragraphs outside tables in some cases. I guess the markup has been neglected a bit, and i definately use paragraphs for things that are not paragraphs at all.


The only thing i perhaps disagree on is images - i think they should be part of a paragraph, just like you can use them within a TD or wherever. Consider the case where you perhaps want an inline image, for whatever reason - the only way to do this is within a paragraph.

H][RO
Paranoid (IV) Inmate

From: Australia
Insane since: Oct 2002

posted posted 08-10-2006 07:44

From a semantic point of view, do you think there should ever be a case where you have to type text directly within a div, rather than between heading or paragraph etc tags?

H][RO
Paranoid (IV) Inmate

From: Australia
Insane since: Oct 2002

posted posted 08-10-2006 09:30

Actually thinking about it now, one reason i often use paragraph is to center things such as tables - which from memory can be difficult to center otherwise

DL-44
Lunatic (VI) Inmate

From: under the bed
Insane since: Feb 2000

posted posted 08-10-2006 14:26
quote:

H][RO said:

From a semantic point of view, do you think there should ever be a case where you have to type text directly within a div, rather than between heading or paragraph etc tags?



No.

quote:

H][RO said:

Actually thinking about it now, one reason i often use paragraph is to center things such as tables - which from memory can be difficult to center otherwise



I don't see how centering an element within a pragraph is any easier than centering it within another element

Setting a width for the table via your CSS, and specifying margin:auto; will do the trick...

As for images - if the need arises for an image actually inline, I can see putting it in the paragraph. More often than not, floating the image outside of the paragraph is what is called for.

(Edited by DL-44 on 08-10-2006 14:27)

H][RO
Paranoid (IV) Inmate

From: Australia
Insane since: Oct 2002

posted posted 08-10-2006 17:45
quote:
Setting a width for the table via your CSS, and specifying margin:auto; will do the trick...



In new browsers this works, but not in some older browsers unfortunately. The only way to cover both cases is to do the margin:auto and place the table within a centered element. Obviously there is no need to use paragraphs, divs would probably better - the only reason paragraphs were easier in my situation is that if i placed the table in a paragraph where the text was centered, the table got centered, if the paragraph text was left, so was the table. I guess depending on what your doing you might not need to align the paragraph or table at all and it should be inherited by the text-align of the div. Unfortunately making stuff work for old browsers does change how you would do things sometimes... such is life.


quote:
As for images - if the need arises for an image actually inline, I can see putting it in the paragraph. More often than not, floating the image outside of the paragraph is what is called for.



Yeah this is mostly what happens anyway, image is one of those elements that can be used just about anywhere. Even with links etc.



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu