two lists in one line

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Eglute
    New Member
    • Nov 2006
    • 24

    #1

    two lists in one line

    I have two lists in my page. I want to have them in one line. My code is:

    <html>
    <head><title> my first page</title></head>
    <body>
    <ul>
    <li>apple
    <li>cherry
    <li>peach
    <li>apricot
    </ul>
    <ol>
    <li>tomato
    <li>cucumber
    <li>carrot
    <li>beetroot
    </ol>
    </body>
    </htm>
  • xwero
    New Member
    • Feb 2007
    • 99

    #2
    Originally posted by Eglute
    I have two lists in my page. I want to have them in one line. My code is:

    <html>
    <head><title> my first page</title></head>
    <body>
    <ul>
    <li>apple
    <li>cherry
    <li>peach
    <li>apricot
    </ul>
    <ol>
    <li>tomato
    <li>cucumber
    <li>carrot
    <li>beetroot
    </ol>
    </body>
    </htm>

    use the css style float.
    Code:
    ul, ol { float:left; }

    Comment

    • Eglute
      New Member
      • Nov 2006
      • 24

      #3
      I am only the beginner in html and I don't understand how to use the css style. Maybe you can write a code for me? Thank you.


      Eglute

      Comment

      • xwero
        New Member
        • Feb 2007
        • 99

        #4
        [HTML]
        <html>
        <head><title> my first page</title></head>
        <style>
        ul, ol { float:left; }
        </style>
        <body>
        <ul>
        <li>apple
        <li>cherry
        <li>peach
        <li>apricot
        </ul>
        <ol>
        <li>tomato
        <li>cucumber
        <li>carrot
        <li>beetroot
        </ol>
        </body>
        </htm>
        [/HTML]
        I used the style tag for this but if you want to style your whole website it's best to separate the css code from the html code.

        Comment

        • xwero
          New Member
          • Feb 2007
          • 99

          #5
          The real one line code

          [HTML]
          <html>
          <head><title> my first page</title></head>
          <style>
          /* remove browser standard behavoir */
          ul,ol {margin:0;paddi ng:0}
          /* put the lists and list elements on one line */
          ul, ol, li { float:left;disp lay:block; }
          /* put some space between the list items */
          li {padding-left:10px;}
          </style>
          <body>
          <ul>
          <li>apple
          <li>cherry
          <li>peach
          <li>apricot
          </ul>
          <ol>
          <li>tomato
          <li>cucumber
          <li>carrot
          <li>beetroot
          </ol>
          </body>
          </htm>
          [/HTML]

          Comment

          • Eglute
            New Member
            • Nov 2006
            • 24

            #6
            Thanks. This way to solve my problem is very interesting. As for me I used table to solve the problem, but this way is longer than your. Thanks




            Eglute

            Comment

            • xwero
              New Member
              • Feb 2007
              • 99

              #7
              Originally posted by Eglute
              Thanks. This way to solve my problem is very interesting. As for me I used table to solve the problem, but this way is longer than your. Thanks
              Eglute
              A tables layout is bad practice if you don't need it. Everything can be positioned with css.

              Comment

              • AricC
                Recognized Expert Top Contributor
                • Oct 2006
                • 1885

                #8
                Originally posted by Eglute
                Thanks. This way to solve my problem is very interesting. As for me I used table to solve the problem, but this way is longer than your. Thanks
                Eglute
                Tables should be used for data only if anything at all eg. populate a table from a database.

                Comment

                Working...