Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Which is more correct code?

Status
Not open for further replies.

irbk

MIS
Oct 20, 2004
578
US
I just ran across some code that brought up an intresting question. Never really had this issue before and now I'm not sure which way of coding is "more correct" then the other. Here is the situation. We want to render the page like so

Paragraph heading here, no bold

Paragraph here, explaining what ever it was that was mentioned in the paragraph heading above, blah, blah blah...

As I was doing XHTML compliance of some one elses code, I noticed that they coded the page 2 different ways.

Option 1 (and probally the "more correct" way)
Code:
<p>
     Paragraph heading here, no bold
</p>
<p>
     Paragraph here, explaining what ever it was that was mentioned in the paragraph heading above, blah, blah blah...
</p>
Option 2 they accomplished the same layout, but using different code
Code:
<p>
     Paragraph heading here, no bold<br/><br/>
Paragraph here, explaining what ever it was that was mentioned in the paragraph heading above, blah, blah blah...
</p>
Both pieces of code render the same way, but I'm currious to know which is the "more correct" way? My guess is putting them in 2 different paragraph tag's, but I just don't know.

Thanks in advance!
 
So, dispite monksnake's mention of option 2 (which I think (s)he may have typed incorrectly), it sounds like you both agree with the article that Option 1 is correct because one should minimize the use of the <br/> element.

Thanks.
 
are they two separate paragraphs? then use two separate p tags.

but you kind of told us/yourself what it should be didin't you ?

<p>
Paragraph heading here, no bold
</p>
<p>
Paragraph here, explaining what ever it was that was mentioned in the paragraph heading above, blah, blah blah...
</p>


so therefore shouldn't it be
Code:
<h6>paragraph HEADING</h6>
<p>paragraph text</p>

of course you can use which eve <h> number tag you want, or is free or gives you generic sizing you desire.

but can easily format with CSS for desired effect anyhow.

Well that's what i'd do

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
lol - thought that your suggestion of option 2 seemd to contradict your comment
This page basically says to minimize <br /> tag usage

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
I agree that they should be in <h> tags as they are a "header" to the following paragraph. I'm going to contact the page author and make sure they are ok with that.

Thanks all.
 
If the author simply wrote the content then it should make no difference to them how you mark it up.

If the first 'para' is indeed a heading then it should use an <h> tag as was pointed out.

You can make that <h> tag look just like the paragraph text if you wish to. The html tag does not and should not create the style.

<honk>*:O)</honk>

Tyres: Mine's a pint of the black stuff.
Mike: You can't drink a pint of Bovril.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top