How do I prevent a line break occurring before an unordered list?

后端 未结 5 1441
迷失自我
迷失自我 2021-01-17 12:48

My web-app framework renders form errors for each field in an unordered list

    immediately following the invalid field. My problem is that I haven\'t b
相关标签:
5条回答
  • 2021-01-17 13:20

    What about setting the p tag to display: inline as well? Is that an option?

    p { display: inline; }
    

    As for the p tag issue... I don't believe the W3C specifications allow an unordered list tag within a paragraph tag. From http://www.w3.org/TR/html401/struct/text.html#h-9.3.1:

    The P element represents a paragraph. It cannot contain block-level elements (including P itself).

    0 讨论(0)
  • 2021-01-17 13:24

    Just one last bit:

    ul.errorlist {
      display: inline;
      list-style-type: none; 
    }
    
    0 讨论(0)
  • 2021-01-17 13:29

    Do you just want to eliminate the space between the paragraph and the list?

    If so, use:

    ul.errorlist {
        margin-top:0;
    }
    

    Then add "margin-bottom:0;" to the paragraph (or just put the errorlist inside the p tags). If you also want the list to display on a single line, use display:inline as the others suggested.

    0 讨论(0)
  • 2021-01-17 13:39

    If you can't change the html then your problem is that the ul has no element around it that you can style.

    If you use javascript, if you can know when an error happens, then you can add a <p> or <span> around the <ul> and then style that so that it will be inline.

    This link shows, about 1/2 way down, using the <p> tag for this purpose.

    http://www.alistapart.com/articles/taminglists/

    If you are just trying to do this in css I believe you will be out of luck. You may ask if they can put a enclosing tag around the error list so you are able to style it.

    0 讨论(0)
  • 2021-01-17 13:41
    ul.errorlist { display: inline; margin: 0; }
    
    0 讨论(0)
提交回复
热议问题