9 Replies Latest reply on Aug 22, 2007 5:17 AM by Newsgroup_User

    Can I put a <h1> inside a <ul>?

    ~Billy~
      Could someone answer this question. I have posted it in two dedicated HTML forums and from each forum recieved two opposing answers -

      Can I put a <h1,2,3 etc> tag inside a <ul></ul> eg -

      ul>
      <li><h1>1</h1></li>
      <li><h1>2</h1></li>
      </ul>

      The first set of replies said "no" I cant, I can only put the <h1> before the list - because you dont have a headline within a list.
      The second answer said "yes" I can html-wise, but I tend to agree more with the first answer as it is not scematicaly correct.

      Can someone clear it up for me?

        • 1. Re: Can I put a &lt;h1&gt; inside a &lt;ul&gt;?
          Level 7
          Why don't you put the code in an html document & use Dreamweaver's
          validation tool to check it.

          This code;

          <ul>
          <bullet>
          <li><h1>1</h1></li>
          <li><h1>2</h1></li>
          </bullet>
          </ul>
          </body>

          Gets the following results;

          The tag name: "bullet" Not found in currently active versions.[HTML 4.0]
          The tag: "li" is not allowed within: "bullet" It is only allowed within:
          dir, menu, ol, ul.[HTML 4.0]

          This code;

          <ul>
          <bullet>
          <ul><h1>1</h1></ul>
          <ul><h1>2</h1></ul>
          </bullet>
          </ul>

          Gets the following results;

          The tag name: "bullet" Not found in currently active versions.[HTML 4.0]
          The tag: "ul" is not allowed within: "bullet" It is only allowed within:
          button, del, fieldset, iframe, ins, noframes, noscript, object, td, th.[HTML
          4.0]
          The tag: "h1" is not allowed within: "ul" It is only allowed within: button,
          del, fieldset, iframe, ins, noframes, noscript, object, td, th.[HTML 4.0]

          "~Billy~" <webforumsuser@macromedia.com> wrote in message
          news:fagqhj$8va$1@forums.macromedia.com...
          > Could someone answer this question. I have posted it in two dedicated HTML
          > forums and from each forum recieved two opposing answers -
          >
          > Can I put a <h1,2,3 etc> tag inside a eg -
          >
          > ul>
          >
          • <h1>1</h1></li>
            >
          • <h1>2</h1></li>
            >

          >
          > The first set of replies said "no" I cant, I can only put the <h1> before
          > the
          > list - because you dont have a headline within a list.
          > The second answer said "yes" I can html-wise, but I tend to agree more
          > with
          > the first answer as it is not scematicaly correct.
          >
          > Can someone clear it up for me?
          >
          >
          >

          • 2. Re: Can I put a &lt;h1&gt; inside a &lt;ul&gt;?
            Kieran Briggs
            You can put a h tag into a list but it won't validate. H1 is a block level tag adn should only be used at block level. If you are trying to create a list of things with headings to show what they are, have you thought of using a definition list instead of a standard <ul>
            • 3. Re: Can I put a &lt;h1&gt; inside a &lt;ul&gt;?
              ~Billy~ Level 1
              Thanks, I read you loud and clear! I guess also in real print you do not have a heading inside a list, so the same applies in html.

              Thanks again.
              • 4. Re: Can I put a &lt;h1&gt; inside a &lt;ul&gt;?
                Level 7
                .oO(kieran_briggs)

                >You can put a h tag into a list but it won't validate.

                It will.

                >H1 is a block level tag
                >adn should only be used at block level.

                List items are block-level. You can put whatever you want into them.

                >If you are trying to create a list of
                >things with headings to show what they are, have you thought of using a
                >definition list instead of a standard


                <ul>
                <li>
                <h2>heading</h2>
                <p>some text</p>
                </li>
                <li>
                <h2>heading</h2>
                <p>some text</p>
                </li>
                <li>
                <h2>heading</h2>
                <p>some text</p>
                </li>
                </ul>

                is perfectly valid strict HTML.

                Micha
                • 5. Re: Can I put a &lt;h1&gt; inside a &lt;ul&gt;?
                  Level 7
                  .oO(Michael Fesser)

                  >.oO(kieran_briggs)
                  >
                  >>You can put a h tag into a list but it won't validate.
                  >
                  >It will.

                  To be more precise: It will validate, if the heading is inside a list
                  item. Of course it won't, if the heading is directly placed into the
                  list, because a 'ul' or 'ol' element only allows 'li' elements.

                  Micha
                  • 6. Re: Can I put a &lt;h1&gt; inside a &lt;ul&gt;?
                    Level 7
                    <bullet> has nothing to do with the actual code, that's part of the code the
                    forum spits out - well from a newsreader point of view.... not sure what
                    happens when you copy and paste using the web interface.

                    Putting a heading (Hn) inside a list does validate, so it won't throw a
                    wobbly when you pass the page through the html validator. I guess though,
                    that a heading is not a list item, it's more a heading for the actual list,
                    so semantically it would go outside the list I guess... comes down to your
                    own preference really :-)


                    --
                    Nadia
                    Adobe® Community Expert : Dreamweaver
                    ----------------------------------------
                    CSS Templates |Tutorials |SEO Articles
                    http://www.DreamweaverResources.com
                    ~ Customisation Service Available ~
                    http://www.csstemplates.com.au
                    ----------------------------------------------------



                    "EasyLancer" <me@me.com> wrote in message
                    news:fah2qn$hch$1@forums.macromedia.com...
                    > Why don't you put the code in an html document & use Dreamweaver's
                    > validation tool to check it.
                    >
                    > This code;
                    >
                    > <ul>
                    > <bullet>
                    > <li><h1>1</h1></li>
                    > <li><h1>2</h1></li>
                    > </bullet>
                    > </ul>
                    > </body>
                    >
                    > Gets the following results;
                    >
                    > The tag name: "bullet" Not found in currently active versions.[HTML 4.0]
                    > The tag: "li" is not allowed within: "bullet" It is only allowed within:
                    > dir, menu, ol, ul.[HTML 4.0]
                    >
                    > This code;
                    >
                    > <ul>
                    > <bullet>
                    > <ul><h1>1</h1></ul>
                    > <ul><h1>2</h1></ul>
                    > </bullet>
                    > </ul>
                    >
                    > Gets the following results;
                    >
                    > The tag name: "bullet" Not found in currently active versions.[HTML 4.0]
                    > The tag: "ul" is not allowed within: "bullet" It is only allowed within:
                    > button, del, fieldset, iframe, ins, noframes, noscript, object, td,
                    > th.[HTML 4.0]
                    > The tag: "h1" is not allowed within: "ul" It is only allowed within:
                    > button, del, fieldset, iframe, ins, noframes, noscript, object, td,
                    > th.[HTML 4.0]
                    >
                    > "~Billy~" <webforumsuser@macromedia.com> wrote in message
                    > news:fagqhj$8va$1@forums.macromedia.com...
                    >> Could someone answer this question. I have posted it in two dedicated
                    >> HTML
                    >> forums and from each forum recieved two opposing answers -
                    >>
                    >> Can I put a <h1,2,3 etc> tag inside a eg -
                    >>
                    >> ul>
                    >>
                    • <h1>1</h1></li>
                      >>
                    • <h1>2</h1></li>
                      >>

                    >>
                    >> The first set of replies said "no" I cant, I can only put the <h1>
                    >> before the
                    >> list - because you dont have a headline within a list.
                    >> The second answer said "yes" I can html-wise, but I tend to agree more
                    >> with
                    >> the first answer as it is not scematicaly correct.
                    >>
                    >> Can someone clear it up for me?
                    >>
                    >>
                    >>
                    >


                    • 7. Re: Can I put a &lt;h1&gt; inside a &lt;ul&gt;?
                      Level 7
                      "Michael Fesser" <netizen@gmx.de> wrote in message
                      news:js6oc31mpivdudli3pl0jhapnb4bssu3mc@4ax.com...
                      > .oO(Michael Fesser)
                      >
                      >>.oO(kieran_briggs)
                      >>
                      >>>You can put a h tag into a list but it won't validate.
                      >>
                      >>It will.
                      >
                      > To be more precise: It will validate, if the heading is inside a list
                      > item. Of course it won't, if the heading is directly placed into the
                      > list, because a 'ul' or 'ol' element only allows 'li' elements.


                      Good, you were more precise than I ;-)



                      --
                      Nadia
                      Adobe® Community Expert : Dreamweaver
                      ----------------------------------------
                      CSS Templates |Tutorials |SEO Articles
                      http://www.DreamweaverResources.com
                      ~ Customisation Service Available ~
                      http://www.csstemplates.com.au
                      ----------------------------------------------------
                      Spry Widget Examples
                      http://www.dreamweaverresources.com/spry-widgets/
                      ----------------------------------------------------


                      • 8. Re: Can I put a &lt;h1&gt; inside a &lt;ul&gt;?
                        ~Billy~ Level 1
                        Thanks guys! In a nutshell yes I can put a <h1> in a list if I want, but its not really very good practice to do it. A list is for lists. I guess there are occasions when a list may require a heading, but I could just put the heading infront of the list, not inside it.
                        • 9. Re: Can I put a &lt;h1&gt; inside a &lt;ul&gt;?
                          Level 7
                          On Wed, 22 Aug 2007 13:19:57 +0200, Michael Fesser <netizen@gmx.de>
                          wrote:


                          >To be more precise: It will validate, if the heading is inside a list
                          >item. Of course it won't, if the heading is directly placed into the
                          >list, because a 'ul' or 'ol' element only allows 'li' elements.
                          >
                          >Micha


                          What I tried to do many months ago was to give a list a heading like
                          this

                          <ul id="nav">
                          <h1>One</h1>
                          <li>One</li>
                          <li>Two</li>
                          <li>Three</li>
                          <li>Four</li>
                          </ul>

                          but of course it failed validation - I had to put it inside a div - as
                          it seemed silly to put the heading in the list
                          --

                          ~Malcolm N....
                          ~