• without parent tags?
  • 后端 未结 7 841
    生来不讨喜
    生来不讨喜 2021-01-13 02:23

    Is it ok to use

  • tags without parent tags?

    i.e.

  • some copy
  • or must it be..

  • 相关标签:
    7条回答
    • 2021-01-13 02:29

      No, that would definitely be invalid (X)HTML. I mean, you could, and the browser might render it correctly if you're lucky (IE in particular, as it tends to be especially lenient), but there's far from any guarantee. You should always enclose <li> tags with either <ul> (unordered list) or <ol> (ordered list). Why wouldn't you want to anyway?

      0 讨论(0)
    • 2021-01-13 02:32

      No, using a li element without a parent ul or ol element would be invalid.

      0 讨论(0)
    • 2021-01-13 02:33

      li = list item, if it's without parents where's the list?

      http://www.w3schools.com/TAGS/tag_li.asp

      http://www.w3.org/TR/html401/struct/lists.html

      0 讨论(0)
    • 2021-01-13 02:41

      Proper HTML (not to mention strict XHTML) should be:

      <ul>
          <li>whatever</li>
      </ul>
      
      0 讨论(0)
    • 2021-01-13 02:41

      I checked the validation of the code below at Markup Validation Service of W3C :

      <li>item 1</li>
      <li>item 2</li>
      

      and the result is :

      document type does not allow element "LI" here; missing one of "UL", "OL", "DIR", "MENU" start-tag

      0 讨论(0)
    • 2021-01-13 02:47

      No, while it might work in some browsers, it is invalid HTML.

      0 讨论(0)
    提交回复
    热议问题