メインコンテンツへスキップ

ol要素


1.仕様

OL要素は、
順序付けられている
項目の一覧を
表します。

OL - - (li)* +(%Scriptsupporting) -- ordered list. (Normal elements.) [Flow|Palpablelimited] --

ol

順序付き一覧 (ordered list)

種類

通常要素

カテゴリ
  • フローコンテンツ
  • パルパブルコンテンツ(条件付き)

要素の子に少なくとも1つの li要素が含まれる場合は、パルパブルコンテンツ。

コンテンツモデル
0個以上の<li>要素 オプションでスクリプトをサポートする要素が混在

0個以上の<li>要素が配置できます。オプションで、スクリプトをサポートする要素を混在して配置できます。

スクリプトをサポートする要素に分類される要素は、<script>要素, <template>要素 です。

タグの省略

どちらのタグも省略できません。

コンテンツ属性
グローバル属性 他
reversed属性
リストが降順
start属性
マーカーの開始値
type属性
マーカーの種類
DOM インターフェイス
HTMLOListElement
  1. [Exposed=Window]
  2. interface HTMLOListElement : HTMLElement {
  3. [HTMLConstructor] constructor();
  4.  
  5. [CEReactions] attribute boolean reversed;
  6. [CEReactions] attribute long start;
  7. [CEReactions] attribute DOMString type;
  8.  
  9. // also has obsolete members
  10. };
HTMLElement
  1. [Exposed=Window]
  2. interface HTMLElement : Element {
  3. [HTMLConstructor] constructor();
  4.  
  5. // metadata attributes
  6. [CEReactions] attribute DOMString title;
  7. [CEReactions] attribute DOMString lang;
  8. [CEReactions] attribute boolean translate;
  9. [CEReactions] attribute DOMString dir;
  10.  
  11. // user interaction
  12. [CEReactions] attribute (boolean or unrestricted double or DOMString)? hidden;
  13. [CEReactions] attribute DOMString inert;
  14. undefined click();
  15. [CEReactions] attribute DOMString accessKey;
  16. readonly attribute DOMString accessKeyLabel;
  17. [CEReactions] attribute boolean draggable;
  18. [CEReactions] attribute boolean spellcheck;
  19. [CEReactions] attribute DOMString writingSuggestions;
  20. [CEReactions] attribute DOMString autocapitalize;
  21.  
  22. [CEReactions] attribute [LegacyNullToEmptyString] DOMString innerText;
  23. [CEReactions] attribute [LegacyNullToEmptyString] DOMString outerText;
  24.  
  25. ElementInternals attachInternals();
  26.  
  27. // The popover API
  28. undefined showPopover();
  29. undefined hidePopover();
  30. boolean togglePopover(optional boolean force);
  31. [CEReactions] attribute DOMString? popover;
  32. };
  33.  
  34. HTMLElement includes GlobalEventHandlers;
  35. HTMLElement includes ElementContentEditable;
  36. HTMLElement includes HTMLOrSVGElement;
Element
  1. [Exposed=Window]
  2. interface Element : Node {
  3. readonly attribute DOMString? namespaceURI;
  4. readonly attribute DOMString? prefix;
  5. readonly attribute DOMString localName;
  6. readonly attribute DOMString tagName;
  7.  
  8. [CEReactions] attribute DOMString id;
  9. [CEReactions] attribute DOMString className;
  10. [SameObject, PutForwards=value] readonly attribute DOMTokenList classList;
  11. [CEReactions, Unscopable] attribute DOMString slot;
  12.  
  13. boolean hasAttributes();
  14. [SameObject] readonly attribute NamedNodeMap attributes;
  15. sequence<DOMString> getAttributeNames();
  16. DOMString? getAttribute(DOMString qualifiedName);
  17. DOMString? getAttributeNS(DOMString? namespace, DOMString localName);
  18. [CEReactions] undefined setAttribute(DOMString qualifiedName, DOMString value);
  19. [CEReactions] undefined setAttributeNS(DOMString? namespace, DOMString qualifiedName, DOMString value);
  20. [CEReactions] undefined removeAttribute(DOMString qualifiedName);
  21. [CEReactions] undefined removeAttributeNS(DOMString? namespace, DOMString localName);
  22. [CEReactions] boolean toggleAttribute(DOMString qualifiedName, optional boolean force);
  23. boolean hasAttribute(DOMString qualifiedName);
  24. boolean hasAttributeNS(DOMString? namespace, DOMString localName);
  25.  
  26. Attr? getAttributeNode(DOMString qualifiedName);
  27. Attr? getAttributeNodeNS(DOMString? namespace, DOMString localName);
  28. [CEReactions] Attr? setAttributeNode(Attr attr);
  29. [CEReactions] Attr? setAttributeNodeNS(Attr attr);
  30. [CEReactions] Attr removeAttributeNode(Attr attr);
  31.  
  32. ShadowRoot attachShadow(ShadowRootInit init);
  33. readonly attribute ShadowRoot? shadowRoot;
  34.  
  35. Element? closest(DOMString selectors);
  36. boolean matches(DOMString selectors);
  37. boolean webkitMatchesSelector(DOMString selectors); // legacy alias of .matches
  38.  
  39. HTMLCollection getElementsByTagName(DOMString qualifiedName);
  40. HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName);
  41. HTMLCollection getElementsByClassName(DOMString classNames);
  42.  
  43. [CEReactions] Element? insertAdjacentElement(DOMString where, Element element); // legacy
  44. undefined insertAdjacentText(DOMString where, DOMString data); // legacy
  45. };
GlobalEventHandlers
  1. interface mixin GlobalEventHandlers {
  2. attribute EventHandler onabort;
  3. attribute EventHandler onauxclick;
  4. attribute EventHandler onbeforeinput;
  5. attribute EventHandler onbeforematch;
  6. attribute EventHandler onbeforetoggle;
  7. attribute EventHandler onblur;
  8. attribute EventHandler oncancel;
  9. attribute EventHandler oncanplay;
  10. attribute EventHandler oncanplaythrough;
  11. attribute EventHandler onchange;
  12. attribute EventHandler onclick;
  13. attribute EventHandler onclose;
  14. attribute EventHandler oncontextlost;
  15. attribute EventHandler oncontextmenu;
  16. attribute EventHandler oncontextrestored;
  17. attribute EventHandler oncopy;
  18. attribute EventHandler oncuechange;
  19. attribute EventHandler oncut;
  20. attribute EventHandler ondblclick;
  21. attribute EventHandler ondrag;
  22. attribute EventHandler ondragend;
  23. attribute EventHandler ondragenter;
  24. attribute EventHandler ondragleave;
  25. attribute EventHandler ondragover;
  26. attribute EventHandler ondragstart;
  27. attribute EventHandler ondrop;
  28. attribute EventHandler ondurationchange;
  29. attribute EventHandler onemptied;
  30. attribute EventHandler onended;
  31. attribute OnErrorEventHandler onerror;
  32. attribute EventHandler onfocus;
  33. attribute EventHandler onformdata;
  34. attribute EventHandler oninput;
  35. attribute EventHandler oninvalid;
  36. attribute EventHandler onkeydown;
  37. attribute EventHandler onkeypress;
  38. attribute EventHandler onkeyup;
  39. attribute EventHandler onload;
  40. attribute EventHandler onloadeddata;
  41. attribute EventHandler onloadedmetadata;
  42. attribute EventHandler onloadstart;
  43. attribute EventHandler onmousedown;
  44. [LegacyLenientThis] attribute EventHandler onmouseenter;
  45. [LegacyLenientThis] attribute EventHandler onmouseleave;
  46. attribute EventHandler onmousemove;
  47. attribute EventHandler onmouseout;
  48. attribute EventHandler onmouseover;
  49. attribute EventHandler onmouseup;
  50. attribute EventHandler onpaste;
  51. attribute EventHandler onpause;
  52. attribute EventHandler onplay;
  53. attribute EventHandler onplaying;
  54. attribute EventHandler onprogress;
  55. attribute EventHandler onratechange;
  56. attribute EventHandler onreset;
  57. attribute EventHandler onresize;
  58. attribute EventHandler onscroll;
  59. attribute EventHandler onscrollend;
  60. attribute EventHandler onsecuritypolicyviolation;
  61. attribute EventHandler onseeked;
  62. attribute EventHandler onseeking;
  63. attribute EventHandler onselect;
  64. attribute EventHandler onslotchange;
  65. attribute EventHandler onstalled;
  66. attribute EventHandler onsubmit;
  67. attribute EventHandler onsuspend;
  68. attribute EventHandler ontimeupdate;
  69. attribute EventHandler ontoggle;
  70. attribute EventHandler onvolumechange;
  71. attribute EventHandler onwaiting;
  72. attribute EventHandler onwebkitanimationend;
  73. attribute EventHandler onwebkitanimationiteration;
  74. attribute EventHandler onwebkitanimationstart;
  75. attribute EventHandler onwebkittransitionend;
  76. attribute EventHandler onwheel;
  77. };
ElementContentEditable
  1. interface mixin ElementContentEditable {
  2. [CEReactions] attribute DOMString contentEditable;
  3. [CEReactions] attribute DOMString enterKeyHint;
  4. readonly attribute boolean isContentEditable;
  5. [CEReactions] attribute DOMString inputMode;
  6. };
HTMLOrSVGElement
  1. interface mixin HTMLOrSVGElement {
  2. [SameObject] readonly attribute DOMStringMap dataset;
  3. attribute DOMString nonce; // intentionally no [CEReactions]
  4.  
  5. [CEReactions] attribute boolean autofocus;
  6. [CEReactions] attribute long tabIndex;
  7. undefined focus(optional FocusOptions options = {});
  8. undefined blur();
  9. };
ARIA in HTML
暗黙的="list" ARIAロール="あり" aria-* 属性="GlobalAny"

暗黙的な ARIAセマンティクスは、role=list です。

作成者が要素に指定してもよい ARIAロール値は、 group, listbox, menu, menubar, none, presentation, radiogroup, tablist, toolbar, tree です。

グローバル aria-* 属性と、許可されたロールに適用される任意の aria-* 属性が記述できます。

レンダリング
ブロックボックス
リスト
  1. ol {
  2. display: block;
  3. margin-block: 1em;
  4. padding-inline-start: 40px;
  5. counter-reset: list-item;
  6. list-style-type: decimal;
  7. unicode-bidi: isolate;
  8. }
  9. :is(dir, dl, menu, ol, ul) ol {
  10. margin-block: 0;
  11. }
  12. ol[type="1"] {
  13. list-style-type: decimal;
  14. }
  15. ol[type=a s] {
  16. list-style-type: lower-alpha;
  17. }
  18. ol[type=A s] {
  19. list-style-type: upper-alpha;
  20. }
  21. ol[type=i s] {
  22. list-style-type: lower-roman;
  23. }
  24. ol[type=I s] {
  25. list-style-type: upper-roman;
  26. }

CSS を大雑把に読むと、 ブロックレベルのブロックコンテナボックス(ブロックボックス)を生成します。 などになります。

説明
ol要素は、順序付けられている項目の一覧を表します。

ol要素は、項目(アイテム・item)の一覧(リスト・list)を表します。項目が意図的に順序付けられている為、順序を変更すると文書(ドキュメント・document)の意味が変わります。項目の順序に意味がない場合は、ul要素を用います。
リストの項目は、ol要素の li要素の子ノードで、ツリー順になっています。

  1. <!DOCTYPE html>
  2. <html lang="ja">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>ol要素の例 - (Example of ol element) | 離珠のHTMLでしぃ!</title>
  6. </head>
  7. <body>
  8. <h1>ol要素の例</h1>
  9. <ol>
  10. <li>1番目のアイテム</li>
  11. <li>2番目のアイテム</li>
  12. </ol>
  13. </body>
  14. </html>

このサンプルへのリンクです。
(./exol.htm)

JSONデータ
JSON形式での、データのイメージです。
  1. {
  2. "ol": {
  3. "check": "2024-09-01",
  4. "group": "List",
  5. "element": "- - (li)* +(%Scriptsupporting) -- ordered list. (Normal elements.) [Flow|Palpablelimited] --",
  6. "attlist": {
  7. "%Global;": "",
  8. "reversed": "(reversed) #IMPLIED -- Number the list backwards --",
  9. "start": "NUMBER #IMPLIED -- Starting value of the list --",
  10. "type": "CDATA #IMPLIED -- Kind of list marker --",
  11. },
  12. "comment": "順序付き一覧 (ordered list)",
  13. "point": "順序付けられている項目の一覧を表します。",
  14. "description": [
  15. "項目(アイテム・item)の一覧(リスト・list)を表します。項目が意図的に順序付けられている為、順序を変更すると文書(ドキュメント・document)の意味が変わります。項目の順序に意味がない場合は、ul要素を用います。",
  16. "リストの項目は、ol要素の li要素の子ノードで、ツリー順になっています。",
  17. ],
  18. "kind": "Normal",
  19. "categories": [
  20. "Flow",
  21. "Palpablelimited",
  22. ],
  23. "categoriessupplement": "要素の子に少なくとも1つの li要素が含まれる場合は、パルパブルコンテンツ。",
  24. "used": "parent (%Flow)*",
  25. "contentmodel": "ol (li)* +(%Scriptsupporting)",
  26. "tag": [
  27. "-",
  28. "-",
  29. ],
  30. "attributes": {
  31. "reversed": "リストが降順",
  32. "start": "マーカーの開始値",
  33. "type": "マーカーの種類",
  34. },
  35. "dominterface": "HTMLOListElement",
  36. "rendering": [
  37. "Lists",
  38. "Bidirectional",
  39. ],
  40. "reference": [
  41. {
  42. "title": "HTML Living Standard. 4.4.5 The ol element.",
  43. "href": "https://html.spec.whatwg.org/multipage/grouping-content.html#the-ol-element",
  44. "heading": "HTML Living Standard. 4.4.5 The ol element",
  45. "sub": "Last Updated 27 August 2024",
  46. },
  47. {
  48. "title": "HTML Living Standard. 15 Rendering 15.3.7 Lists.",
  49. "href": "https://html.spec.whatwg.org/multipage/rendering.html#lists",
  50. "heading": "HTML Living Standard. 15 Rendering 15.3.7 Lists",
  51. "sub": "Last Updated 27 August 2024",
  52. },
  53. {
  54. "title": "HTML 5.2 W3C Recommendation. 4.4.6 The ol element. W3C Recommendation, 14 December 2017.",
  55. "href": "https://www.w3.org/TR/2017/REC-html52-20171214/grouping-content.html#the-ol-element",
  56. "heading": "HTML 5.2 W3C 勧告. 4.4.6 The ol element",
  57. "sub": "W3C勧告、2017年12月14日",
  58. },
  59. {
  60. "title": "HTML 5.2 W3C Recommendation. 10.3.8. Lists.",
  61. "href": "https://www.w3.org/TR/2017/REC-html52-20171214/rendering.html#section-lists",
  62. "heading": "HTML 5.2 W3C 勧告. 10.3.8. Lists",
  63. "sub": "W3C勧告、2017年12月14日",
  64. },
  65. {
  66. "title": "HTML 5.1 W3C Recommendation. 4.4.5 The ol element. W3C Recommendation, 1 November 2016.",
  67. "href": "https://www.w3.org/TR/2016/REC-html51-20161101/grouping-content.html#the-ol-element",
  68. "heading": "HTML 5.1 W3C 勧告. 4.4.5 The ol element",
  69. "sub": "W3C勧告、2016年11月1日",
  70. },
  71. {
  72. "title": "HTML 5.1 W3C Recommendation. 10.3.8. Lists. W3C Recommendation, 1 November 2016.",
  73. "href": "https://www.w3.org/TR/2016/REC-html51-20161101/rendering.html#section-lists",
  74. "heading": "HTML 5.1 W3C 勧告. 10.3.8. Lists",
  75. "sub": "W3C勧告、2016年11月1日",
  76. },
  77. {
  78. "title": "HTML 5 W3C Recommendation. 4.4.5 The ol element. W3C Recommendation, 28 October 2014.",
  79. "href": "https://www.w3.org/TR/2014/REC-html5-20141028/grouping-content.html#the-ol-element",
  80. "heading": "HTML 5 W3C 勧告. 4.4.5 The ol element",
  81. "sub": "W3C勧告、2014年10月28日",
  82. },
  83. {
  84. "title": "HTML 5 W3C Recommendation. 10.3.8 Lists. W3C Recommendation, 28 October 2014.",
  85. "href": "https://www.w3.org/TR/2014/REC-html5-20141028/rendering.html#lists",
  86. "heading": "HTML 5 W3C 勧告. 10.3.8 Lists",
  87. "sub": "W3C勧告、2014年10月28日",
  88. },
  89. {
  90. "title": "HTML 4.01 Specification W3C Recommendation. 10.2 Unordered lists (UL), ordered lists (OL), and list items (LI). W3C Recommendation 24 December 1999.",
  91. "href": "https://www.w3.org/TR/html401/struct/lists.html#h-10.2",
  92. "heading": "HTML 4.01 Specification W3C 勧告. 10.2 Unordered lists (UL), ordered lists (OL), and list items (LI)",
  93. "sub": "W3C勧告1999年12月24日",
  94. },
  95. {
  96. "title": "HTML 3.2 Reference Specification. W3C Recommendation 14-Jan-1997.",
  97. "href": "https://www.w3.org/TR/2018/SPSD-html32-20180315/",
  98. "heading": "HTML 3.2 Reference Specification",
  99. "sub": "W3C勧告1997年1月14日",
  100. },
  101. {
  102. "title": "Hypertext Markup Language - 2.0. November 1995.",
  103. "href": "https://www.ietf.org/rfc/rfc1866.txt",
  104. "heading": "Hypertext Markup Language - 2.0",
  105. "sub": "November 1995",
  106. },
  107. {
  108. "title": "Hypertext Markup Language (HTML). June 1993.",
  109. "href": "https://www.w3.org/MarkUp/draft-ietf-iiir-html-01.txt",
  110. "heading": "Hypertext Markup Language (HTML)",
  111. "sub": "June 1993",
  112. },
  113. {
  114. "title": "MDN Web Docs. HTML <ol>: The Ordered List element.",
  115. "href": "https://developer.mozilla.org/ja/docs/Web/HTML/Element/ol",
  116. "heading": "<ol>: 順序付きリスト要素 - HTML: ハイパーテキストマークアップ言語 | MDN",
  117. },
  118. ],
  119. "version": {
  120. "first": "HTML",
  121. "latest": "HTML Living Standard",
  122. },
  123. }
  124. }

注意: 簡易に描画する為に、各項目の後ろに , を付与しています。JSON の形式では、末尾の項目の後には , は付けません。

最終確認日

2024-09-01


2.使用できるコンテキスト

ol要素は、
フローコンテンツを
受け入れる要素に
使用できます。

<ol>要素が使用できるコンテキスト(Context文脈)は、フローコンテンツを受け入れる要素コンテンツとしてです。

body
ol
  1. <body>
  2. <ol>
  3. <li>項目1</li>
  4. <li>項目2</li>
  5. </ol>
  6. </body>

<body>要素のコンテンツの一部として、フローコンテンツである<ol>要素を配置している例です。


3.コンテンツモデル

ol要素は、
li要素を
配置できます。

<ol>要素子や子孫としてどのようなコンテンツ(Content内容) が含まれなければならないかというと、0 以上の<li>要素およびスクリプトをサポートする要素です。

スクリプトをサポートする要素に分類される要素は、以下の各要素です。

ol
li
Flow
content
  1. <ol>
  2. <li><p>項目1</p></li>
  3. <li><p>項目2</p></li>
  4. </ol>

<ol>要素のコンテンツの一部として、<li>要素を配置している例です。

ブロック
フォーマット
コンテキスト
ブロック
レベル
ボックス

ボックスで表すと、<ol>要素が存在して、その中に <li>要素があります。

<ol>要素は、ブロックレベルブロックコンテナであるボックスを生成します。<ol>要素を含むブロックフォーマットコンテキストがない場合は、新しいブロックフォーマットコンテキストを確立します。<ol>要素は、ブロックレベルのボックスを生成する<li>要素を配置します。なのでここでは、インラインフォーマットコンテキストは確立されません。
尚、この説明は各要素のレンダリングに関する指定が既定値での話で、個々にスタイルを指定した場合はこの限りではありません。


4.コンテンツ属性

ol要素は、
グローバル属性と、
reversed属性,
start属性,
type属性 を
設定できます。

<ol>要素は、グローバル属性reversed属性, start属性, type属性 を設定できます。

reversed属性

  1. <ol >

reversed属性 はブール属性で、存在する場合、リストが降順リストであることを示します。属性を省略した場合、リストは昇順リストになります。

  1. リスト1
  2. リスト2
  3. リスト3

start属性

  1. <ol start="">

start属性 は、リストの開始値を決定するために使用されます。

  1. リスト1
  2. リスト2
  3. リスト3

type属性

  1. <ol type="">

type属性 は、リスト内で使用するマーカーの種類を指定するために使用できます。

  1. リスト1
  2. リスト2
  3. リスト3

組み合わせ

  1. <ol start="" type="">

reversed属性 はブール属性で、存在する場合、リストが降順リストであることを示します。属性を省略した場合、リストは昇順リストになります。

  1. リスト1
  2. リスト2
  3. リスト3

5.DOM インターフェイス

id属性を用いて
getElementById()メソッドで
要素を取得する方法がお勧めです。

ol要素を表すプロパティはないので、id属性を用いて documentgetElementById()メソッドで、要素を取得する方法がお勧めです。この時に取得できるのはHTMLOListElement オブジェクトです。


6.アクセシビリティ

ol要素は、
リスト項目要素を含む
セクションです。

<ol>要素暗黙的なARIAセマンティクスは、role="list" となります。
`list` ロールは、次のようなランドマークを意味します:
リスト項目要素を含むセクションです。リストには、listitemロールを持つ子要素が含まれます。

作成者が<ol>要素に明示的に指定可能なARIA ロール(役割)は以下のとおりです:
group, listbox, menu, menubar, none, presentation, radiogroup, tablist, toolbar, tree

ARIA の状態プロパティについては、すべての要素で使用できるグローバル`aria-*` 属性に加えて、上記のロールに応じて使用可能な`aria-*` 属性が許可されます。

著者は非推奨のdirectoryロールを使用しないでください。


7.レンダリング

  1. ol {
  2. display: block;
  3. margin-block-start: 1em;
  4. margin-block-end: 1em;
  5. padding-inline-start: 40px;
  6. counter-reset: list-item;
  7. list-style-type: decimal;
  8. unicode-bidi: isolate;
  9. }

ol要素は、ブロックレベルのブロックコンテナであるボックスを生成します。

ブロックフォーマットコンテキストに参加して、ブロックフォーマットコンテキストを継承, 確立します。もし、インラインフォーマットコンテキストに参加するコンテンツのみを含む場合は、新しいインラインフォーマットコンテキストを確立します。次に、すべてのインラインコンテンツをラップするルートインラインボックスも生成します。

list-style-type は、リスト項目要素のマーカーを設定します。decimal は、数値です。1 から始まります。

unicode-bidi は、置換されない要素のレンダリングでの Bidirectional text(双方向テキスト) に於いての期待される仕様の様です。

  1. :is(dir, dl, menu, ol, ul) ol {
  2. margin-block-start: 0;
  3. margin-block-end: 0;
  4. }
  5. ol[type="1"] { list-style-type: decimal; }
  6. ol[type=a s] { list-style-type: lower-alpha; }
  7. ol[type=A s] { list-style-type: upper-alpha; }
  8. ol[type=i s] { list-style-type: lower-roman; }
  9. ol[type=I s] { list-style-type: upper-roman; }

ol要素のレンダリングに関する部分を抜粋したものです。ol要素が関わる他の要素のレンダリングに関する部分は省いています。

  1. <div style="list-style-type: ">
  2. <p>リスト1</p>
  3. <p>リスト2</p>
  4. <p>リスト3</p>
  5. </div>

list-style-typeプロパティはリスト項目要素のマーカーを設定します。ここでの提示は、数値カウンタシステムの一部です。 type属性 の機能をスタイルシートに置き換える事が出来ます。ただしユーザーがスタイルシートを無効にした場合に装飾が無効になるので、その辺を意識する場合は属性を用いた方が良いです。

リスト1

リスト2

リスト3

  1. <div class="cdvSample162">
  2. <p>リスト1</p>
  3. <p>リスト2</p>
  4. <p>リスト3</p>
  5. </div>
  1. .cdvSample162 {
  2. padding-left: 2.0em;
  3. counter-reset: ndvDemo162 ;
  4. }
  5. .cdvSample162 > *:first-child ~ * {
  6. counter-increment: ndvDemo162 ;
  7. }
  8. .cdvSample162 > *:before {
  9. content: counter(ndvDemo162, ) ".";
  10. position: absolute;
  11. width: 2.2em;
  12. left: -2.5em; text-align: right;;
  13. text-align: right;;
  14. }
  15. .cdvSample162 > * {
  16. position: relative;
  17. margin: 0;
  18. }

スタイルシートを style属性 ではなくstyle要素などを用いてセレクタで指定する事によって、疑似要素などを用いた例です。

尚、例示で動的に表現する為に、Javascript でスタイルシートを操作していますが、疑似要素の関係で用意したセレクタを選択する方法で動作させています。

リスト1

リスト2

リスト3

  1. <ol class="colSample163">
  2. <li>リスト1</li>
  3. <li>リスト2</li>
  4. <li>リスト3</li>
  5. </ol>
  1. .colSample163 {
  2. list-style-type: none;
  3. }
  4. .colSample163 > * {
  5. position: relative;
  6. }
  7. .colSample163 > *:before {
  8. position: absolute;
  9. left: -2.5em;
  10. content: counter(list-item);
  11. display: table-cell;
  12. vertical-align: middle;
  13. text-align: center;
  14. width: 1.8em;
  15. border-radius: 50%;
  16. background: #F6A38B;
  17. }

マーカーの装飾例です。list-style-typeプロパティnone を指定して、改めて疑似要素でマーカーを表しています。 カウンタを list-item そのまま使用した例示です。

  1. リスト1
  2. リスト2
  3. リスト3

8.気を付ける点

順序

順序に意味のある項目の一覧を表しているので、単なる番号付けとは違います。ol要素ul要素の使い分けが微妙な場合もあるので、順序の意味は意識しましょう。

マーカーの領域

マーカーは一覧に表される項目に付けられます。既定値ではボックスの外に配置されます。マーカーの領域も事前に配慮する必要があります。

項目の一覧

項目の一覧を表しているので、大きなグループなど規模についても考慮が必要かと思います。区分(セクション)などは、順序に意味があってもまとまりが少々大きいかと思います。区分(セクション)の目次などは適切かと思います。
区分(セクション)を開閉式にして一覧できる状態にするという方法もあるので、一概に可否は問えない気を付けるべき事だと思います。