Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> HTML

วิธีสร้างรายการลำดับ (Ordered List) ตัวเลขใน HTML

ใช้แท็ก <ol> พร้อม attribute type="1" สำหรับรายการลำดับตัวเลข 1, 2, 3... (เป็นค่าเริ่มต้นแล้ว ไม่ต้องระบุก็ได้)

ค่าของ type attribute

ค่ารูปแบบ
11, 2, 3... (ค่าเริ่มต้น)
aa, b, c...
AA, B, C...
ii, ii, iii...
II, II, III...

ตัวอย่าง

<!DOCTYPE html>
<html>
<head>
  <title>World Cup Teams</title>
</head>
<body>
  <h1>List of teams for World Cup</h1>
  <ol type="1">
    <li>India</li>
    <li>Australia</li>
    <li>South Africa</li>
    <li>New Zealand</li>
    <li>Pakistan</li>
    <li>Sri Lanka</li>
    <li>West Indies</li>
    <li>Bangladesh</li>
  </ol>
</body>
</html>

ผลลัพธ์

  1. India
  2. Australia
  3. South Africa
  4. New Zealand
  5. Pakistan
  6. Sri Lanka
  7. West Indies
  8. Bangladesh

Attribute เพิ่มเติม

  • start="5" - เริ่มนับจาก 5 แทน 1
  • reversed - นับถอยหลัง (HTML5)