when to use UL or OL in html?

前端 未结 12 2004
陌清茗
陌清茗 2020-12-05 03:58

Seems interchangable?

12条回答
  •  一整个雨季
    2020-12-05 04:22

    Haha, so many answers!

    When HTML first came out, there were OL and UL, which, as all of the other posters have said, meant Ordered List and Unordered List.

    The difference was easy. OLs displayed... a number next to them. Or a roman numeral, or a letter! You could even control whether it used capitalized symbols or lowercase! Cool!

    ULs gave you bullets. 3 types of bullets, even - discs (hollow circles), squares (filled squares), circles (filled circles.)

    There was no CSS. Beyond these attributes, there wasn't really a way to customize the list formats (and margins and indententations and everything else.) So, this distinction was important.

    Nowadays, its all CSS. In fact, the w3 people want you to use styles rather than the html "type" attribute that you used to use. So, using UL vs OL doesn't really matter, if you are one of them newfangled CSS users.

    CSS lets you change the bullet type, or opt to use an image, or change the margins/styles/indentations, or not even display a bullet at all.

    Edit again: This answer isn't really meant to address the semantic merits of UL vs OL. But technically (you know, at the bits and bytes) the above outlines the differences in behavior.

提交回复
热议问题