#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Location
    The Pleiades
    Posts
    298
    Rep Power
    8

    Is this correct?


    Is it valid to put a <h#> tag within a <p> tag?

    Just saves me going the <div> route for a part of a page.

    Regards,

    NM.
  2. #2
  3. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,957
    Rep Power
    1046
    Originally Posted by Nanomech
    Is it valid to put a <h#> tag within a <p> tag?
    No. And it just doesn't make sense semantically. A paragraph may have a heading, but it hardly includes a heading as content. A paragraph is a piece of text.
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Location
    The Pleiades
    Posts
    298
    Rep Power
    8
    Div it is!

    Thanks for your answer.

    Kind regards,

    NM.
  6. #4
  7. Autodidact
    Devshed Novice (500 - 999 posts)

    Join Date
    Mar 2008
    Location
    Canada
    Posts
    741
    Rep Power
    833
    Originally Posted by Nanomech
    Div it is!

    Thanks for your answer.

    Kind regards,

    NM.
    If the content will be inline with no further tags inside, why not use a more semantically meaningful tag like <strong> or <em>? I'm only asking because I don't know what function the <div> tag will serve in the <p> context, but if it's just to highlight important strings of text inside the paragraph, definitely go with one of the tags I suggested.
    Soldiers, from the height of these pyramids forty centuries look down upon you.
    ▪ Napoleon, on the eve of the Battle of the Pyramids
  8. #5
  9. CSS & JS/DOM Adept
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jul 2004
    Location
    USA (verifiably)
    Posts
    20,124
    Rep Power
    4303
    Nanomech, are you trying to make an "inline heading" at the beginning of a paragraph?

    P.S. Thread moved to HTML forum.
    Spreading knowledge, one newbie at a time.

    Check out my blog. | Learn CSS. | PHP includes | X/HTML Validator | CSS validator | Common CSS Mistakes | Common JS Mistakes

    Remember people spend most of their time on other people's sites (so don't violate web design conventions).
  10. #6
  11. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Location
    The Pleiades
    Posts
    298
    Rep Power
    8
    Hey guys,

    Thanks for all your responses, please allow me to clarify.

    So I am creating a simple 'About the company' page.

    I want 3 headings inline with each other, then under them a paragraph, maybe an image in one of them, directly underneath their corresponding headings.

    I know I can use divs, and either float 2 of them and center the third, or display them inline block.

    I suppose I could technically do this with the headings, then do it for the paragraphs, after clearing them.

    Would it be easier to create 3 divs, position them and add the content as needed or float the headings (centering the 3rd) then clearing the paragraphs and doing the same with them??

    I want it to appear like the heading it outside the 'box' so I am planning on adding a border around the paragraphs and not the div (if advised to do it this way).

    Hope you understand my problem a little more as my initial post was quite brief to say the least.

    Kind regards,

    NM.
  12. #7
  13. No Profile Picture
    Permanently Banned
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Location
    Ludhiana
    Posts
    33
    Rep Power
    0
    It doesn't make sense using a heading tag within a paragraph tag.A div acts like a division which makes it semantically correct to use a heading tag with a paragraph tag.
  14. #8
  15. CSS & JS/DOM Adept
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jul 2004
    Location
    USA (verifiably)
    Posts
    20,124
    Rep Power
    4303
    Sorry, I forgot to come back to this. I would most likely use <div>s instead of trying to get the elements to line up otherwise.
    Spreading knowledge, one newbie at a time.

    Check out my blog. | Learn CSS. | PHP includes | X/HTML Validator | CSS validator | Common CSS Mistakes | Common JS Mistakes

    Remember people spend most of their time on other people's sites (so don't violate web design conventions).
  16. #9
  17. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Location
    The Pleiades
    Posts
    298
    Rep Power
    8
    Good morning Kravvitz,

    I ended up going for the div route, centering the headings inside the divs, then applying the border around the paragraph underneath rather than the div to make it appear a 2 separate elements (in a way )

    Kind regards,

    NM.
  18. #10
  19. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    2
    Rep Power
    0

    not correct.


    syntax is not correct. parser will give error.

IMN logo majestic logo threadwatch logo seochat tools logo