1.仕様
UL要素は、
順序付けのない
項目の一覧を
表します。
- ul
-
順序付けなし一覧 (unordered list)
- 種類
-
通常要素
- カテゴリ
-
- フロー
コンテンツ - パルパブル
コンテンツ (条件付き)
要素の子に少なくとも1つの li要素が含まれる場合は、パルパブルコンテンツ。
- フロー
- コンテンツモデル
-
0個以上のli
要素 オプションでスクリプトをサポートする要素 が混在0個以上のli
要素 が配置できます。オプションで、スクリプトをサポートする要素 を混在して配置できます。スクリプトを
サポートする要素 に分類される要素は、script要素 , template要素 です。 - タグの省略
-
どちらのタグも省略できません。
- コンテンツ属性
-
グローバル属性のみ
- DOM インターフェイス
-
HTMLUListElement
[Exposed=Window]
interface HTMLUListElement : HTMLElement {
[HTMLConstructor] constructor();
// also has obsolete members
};
HTMLElement
[Exposed=Window]
interface HTMLElement : Element {
[HTMLConstructor] constructor();
// metadata attributes
[CEReactions] attribute DOMString title;
[CEReactions] attribute DOMString lang;
[CEReactions] attribute boolean translate;
[CEReactions] attribute DOMString dir;
// user interaction
[CEReactions] attribute (boolean or unrestricted double or DOMString)? hidden;
[CEReactions] attribute DOMString inert;
undefined click();
[CEReactions] attribute DOMString accessKey;
readonly attribute DOMString accessKeyLabel;
[CEReactions] attribute boolean draggable;
[CEReactions] attribute boolean spellcheck;
[CEReactions] attribute DOMString writingSuggestions;
[CEReactions] attribute DOMString autocapitalize;
[CEReactions] attribute [LegacyNullToEmptyString] DOMString innerText;
[CEReactions] attribute [LegacyNullToEmptyString] DOMString outerText;
ElementInternals attachInternals();
// The popover API
undefined showPopover();
undefined hidePopover();
boolean togglePopover(optional boolean force);
[CEReactions] attribute DOMString? popover;
};
HTMLElement includes GlobalEventHandlers;
HTMLElement includes ElementContentEditable;
HTMLElement includes HTMLOrSVGElement;
Element
[Exposed=Window]
interface Element : Node {
readonly attribute DOMString? namespaceURI;
readonly attribute DOMString? prefix;
readonly attribute DOMString localName;
readonly attribute DOMString tagName;
[CEReactions] attribute DOMString id;
[CEReactions] attribute DOMString className;
[SameObject, PutForwards=value] readonly attribute DOMTokenList classList;
[CEReactions, Unscopable] attribute DOMString slot;
boolean hasAttributes();
[SameObject] readonly attribute NamedNodeMap attributes;
sequence<DOMString> getAttributeNames();
DOMString? getAttribute(DOMString qualifiedName);
DOMString? getAttributeNS(DOMString? namespace, DOMString localName);
[CEReactions] undefined setAttribute(DOMString qualifiedName, DOMString value);
[CEReactions] undefined setAttributeNS(DOMString? namespace, DOMString qualifiedName, DOMString value);
[CEReactions] undefined removeAttribute(DOMString qualifiedName);
[CEReactions] undefined removeAttributeNS(DOMString? namespace, DOMString localName);
[CEReactions] boolean toggleAttribute(DOMString qualifiedName, optional boolean force);
boolean hasAttribute(DOMString qualifiedName);
boolean hasAttributeNS(DOMString? namespace, DOMString localName);
Attr? getAttributeNode(DOMString qualifiedName);
Attr? getAttributeNodeNS(DOMString? namespace, DOMString localName);
[CEReactions] Attr? setAttributeNode(Attr attr);
[CEReactions] Attr? setAttributeNodeNS(Attr attr);
[CEReactions] Attr removeAttributeNode(Attr attr);
ShadowRoot attachShadow(ShadowRootInit init);
readonly attribute ShadowRoot? shadowRoot;
Element? closest(DOMString selectors);
boolean matches(DOMString selectors);
boolean webkitMatchesSelector(DOMString selectors); // legacy alias of .matches
HTMLCollection getElementsByTagName(DOMString qualifiedName);
HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName);
HTMLCollection getElementsByClassName(DOMString classNames);
[CEReactions] Element? insertAdjacentElement(DOMString where, Element element); // legacy
undefined insertAdjacentText(DOMString where, DOMString data); // legacy
};
GlobalEventHandlers
interface mixin GlobalEventHandlers {
attribute EventHandler onabort;
attribute EventHandler onauxclick;
attribute EventHandler onbeforeinput;
attribute EventHandler onbeforematch;
attribute EventHandler onbeforetoggle;
attribute EventHandler onblur;
attribute EventHandler oncancel;
attribute EventHandler oncanplay;
attribute EventHandler oncanplaythrough;
attribute EventHandler onchange;
attribute EventHandler onclick;
attribute EventHandler onclose;
attribute EventHandler oncontextlost;
attribute EventHandler oncontextmenu;
attribute EventHandler oncontextrestored;
attribute EventHandler oncopy;
attribute EventHandler oncuechange;
attribute EventHandler oncut;
attribute EventHandler ondblclick;
attribute EventHandler ondrag;
attribute EventHandler ondragend;
attribute EventHandler ondragenter;
attribute EventHandler ondragleave;
attribute EventHandler ondragover;
attribute EventHandler ondragstart;
attribute EventHandler ondrop;
attribute EventHandler ondurationchange;
attribute EventHandler onemptied;
attribute EventHandler onended;
attribute OnErrorEventHandler onerror;
attribute EventHandler onfocus;
attribute EventHandler onformdata;
attribute EventHandler oninput;
attribute EventHandler oninvalid;
attribute EventHandler onkeydown;
attribute EventHandler onkeypress;
attribute EventHandler onkeyup;
attribute EventHandler onload;
attribute EventHandler onloadeddata;
attribute EventHandler onloadedmetadata;
attribute EventHandler onloadstart;
attribute EventHandler onmousedown;
[LegacyLenientThis] attribute EventHandler onmouseenter;
[LegacyLenientThis] attribute EventHandler onmouseleave;
attribute EventHandler onmousemove;
attribute EventHandler onmouseout;
attribute EventHandler onmouseover;
attribute EventHandler onmouseup;
attribute EventHandler onpaste;
attribute EventHandler onpause;
attribute EventHandler onplay;
attribute EventHandler onplaying;
attribute EventHandler onprogress;
attribute EventHandler onratechange;
attribute EventHandler onreset;
attribute EventHandler onresize;
attribute EventHandler onscroll;
attribute EventHandler onscrollend;
attribute EventHandler onsecuritypolicyviolation;
attribute EventHandler onseeked;
attribute EventHandler onseeking;
attribute EventHandler onselect;
attribute EventHandler onslotchange;
attribute EventHandler onstalled;
attribute EventHandler onsubmit;
attribute EventHandler onsuspend;
attribute EventHandler ontimeupdate;
attribute EventHandler ontoggle;
attribute EventHandler onvolumechange;
attribute EventHandler onwaiting;
attribute EventHandler onwebkitanimationend;
attribute EventHandler onwebkitanimationiteration;
attribute EventHandler onwebkitanimationstart;
attribute EventHandler onwebkittransitionend;
attribute EventHandler onwheel;
};
ElementContentEditable
interface mixin ElementContentEditable {
[CEReactions] attribute DOMString contentEditable;
[CEReactions] attribute DOMString enterKeyHint;
readonly attribute boolean isContentEditable;
[CEReactions] attribute DOMString inputMode;
};
HTMLOrSVGElement
interface mixin HTMLOrSVGElement {
[SameObject] readonly attribute DOMStringMap dataset;
attribute DOMString nonce; // intentionally no [CEReactions]
[CEReactions] attribute boolean autofocus;
[CEReactions] attribute long tabIndex;
undefined focus(optional FocusOptions options = {});
undefined blur();
};
- ARIA in HTML
-
暗黙的="
list
" ARIAロール="あり" aria-* 属性="GlobalAny
"暗黙的な ARIAセマンティクスは、
role=list
です。作成者が要素に指定してもよい ARIAロール値は、 group, listbox, menu, menubar, none, presentation, radiogroup, tablist, toolbar, tree です。
グローバル aria-* 属性と、許可されたロールに適用される任意の aria-* 属性が記述できます。
- レンダリング
- ブロック
ボックス リスト
ul {
display: block;
margin-block: 1em;
padding-inline-start: 40px;
counter-reset: list-item;
list-style-type: disc;
unicode-bidi: isolate;
}
:is(dir, dl, menu, ol, ul) ul { margin-block: 0; }
:is(dir, menu, ol, ul) ul { list-style-type: circle; }
:is(dir, menu, ol, ul) :is(dir, menu, ol, ul) ul { list-style-type: square; }
ul[type=none i] { list-style-type: none; }
ul[type=disc i] { list-style-type: disc; }
ul[type=circle i] { list-style-type: circle; }
ul[type=square i] { list-style-type: square; }
CSS を大雑把に読むと、 ブロックレベルのブロックコンテナボックス(ブロックボックス)を生成します。 などになります。
- 説明
-
ul
要素 は、順序付けのない項目の一覧を表します。ul
要素 は、項目(アイテム・item)の一覧(リスト・list)を表します。項目の順序は重要ではありません。つまり、順序を変更しても文書(ドキュメント・document)の意味は大きく変わりません。項目の順序に意味がある場合は、ol要素を用います。
リストの項目は、ul要素の li要素の子ノードで、ツリー順になっています。<!DOCTYPE html>
<html lang=
"ja"> <head>
<meta charset=
"utf-8"> <title>ul要素の例 - (Example of ul element) | 離珠のHTMLでしぃ!</title>
</head>
<body>
<h1>ul要素の例</h1>
<ul>
<li>リストアイテムA</li>
<li>リストアイテムB</li>
</ul>
</body>
</html>
このサンプルへのリンクです。
(./exul.htm) - 参照元
-
参照元
- HTML Living Standard. 4.4.6 The ul element (Last Updated 27 August 2024)
- HTML Living Standard. 15 Rendering 15.3.7 Lists (Last Updated 27 August 2024)
- HTML 5.2 W3C 勧告. 4.4.7 The ul element (W3C勧告、2017年12月14日)
- HTML 5.2 W3C 勧告. 10.3.8. Lists (W3C勧告、2017年12月14日)
- HTML 5.1 W3C 勧告. 4.4.6 The ul element (W3C勧告、2016年11月1日)
- HTML 5.1 W3C 勧告. 10.3.8. Lists (W3C勧告、2016年11月1日)
- HTML 4.01 Specification W3C 勧告. 10.2 Unordered lists (UL), ordered lists (OL), and list items (LI) (W3C勧告1999年12月24日)
- HTML 3.2 Reference Specification (W3C勧告1997年1月14日)
- Hypertext Markup Language - 2.0 (November 1995)
- Hypertext Markup Language (HTML) (June 1993)
- <ul>: 順序なしリスト要素 - HTML: ハイパーテキストマークアップ言語 | MDN
- JSONデータ
-
JSON形式での、データのイメージです。
{
"ul": {
"check": "2024-09-01",
"group": "List",
"element": "- - (li)* +(%Scriptsupporting) -- unordered list. (Normal elements.) [Flow|PalpableLimited] --",
"attlist": {"%Global;": ""},
"comment": "順序付けなし一覧 (unordered list)",
"point": "順序付けのない項目の一覧を表します。",
"description": [
"項目(アイテム・item)の一覧(リスト・list)を表します。項目の順序は重要ではありません。つまり、順序を変更しても文書(ドキュメント・document)の意味は大きく変わりません。項目の順序に意味がある場合は、ol要素を用います。",
"リストの項目は、ul要素の li要素の子ノードで、ツリー順になっています。 ",
],
"kind": "Normal",
"categories": [
"Flow",
"PalpableLimited",
],
"categoriessupplement": "要素の子に少なくとも1つの li要素が含まれる場合は、パルパブルコンテンツ。",
"used": "parent (%Flow)*",
"contentmodel": "ul (li)* +(%Scriptsupporting)",
"tag": [
"-",
"-",
],
"attributes": "Global",
"dominterface": "HTMLUListElement",
"rendering": [
"Lists",
"Bidirectional",
],
"reference": [
{
"title": "HTML Living Standard. 4.4.6 The ul element.",
"href": "https://html.spec.whatwg.org/multipage/grouping-content.html#the-ul-element",
"heading": "HTML Living Standard. 4.4.6 The ul element",
"sub": "Last Updated 27 August 2024",
},
{
"title": "HTML Living Standard. 15 Rendering 15.3.7 Lists.",
"href": "https://html.spec.whatwg.org/multipage/rendering.html#lists",
"heading": "HTML Living Standard. 15 Rendering 15.3.7 Lists",
"sub": "Last Updated 27 August 2024",
},
{
"title": "HTML 5.2 W3C Recommendation. 4.4.7 The ul element. W3C Recommendation, 14 December 2017.",
"href": "https://www.w3.org/TR/2017/REC-html52-20171214/grouping-content.html#the-ul-element",
"heading": "HTML 5.2 W3C 勧告. 4.4.7 The ul element",
"sub": "W3C勧告、2017年12月14日",
},
{
"title": "HTML 5.2 W3C Recommendation. 10.3.8. Lists.",
"href": "https://www.w3.org/TR/2017/REC-html52-20171214/rendering.html#section-lists",
"heading": "HTML 5.2 W3C 勧告. 10.3.8. Lists",
"sub": "W3C勧告、2017年12月14日",
},
{
"title": "HTML 5.1 W3C Recommendation. 4.4.6 The ul element. W3C Recommendation, 1 November 2016.",
"href": "https://www.w3.org/TR/2016/REC-html51-20161101/grouping-content.html#the-ul-element",
"heading": "HTML 5.1 W3C 勧告. 4.4.6 The ul element",
"sub": "W3C勧告、2016年11月1日",
},
{
"title": "HTML 5.1 W3C Recommendation. 10.3.8. Lists. W3C Recommendation, 1 November 2016.",
"href": "https://www.w3.org/TR/2016/REC-html51-20161101/rendering.html#section-lists",
"heading": "HTML 5.1 W3C 勧告. 10.3.8. Lists",
"sub": "W3C勧告、2016年11月1日",
},
{
"title": "HTML 4.01 Specification W3C Recommendation. 10.2 Unordered lists (UL), ordered lists (OL), and list items (LI). W3C Recommendation 24 December 1999.",
"href": "https://www.w3.org/TR/html401/struct/lists.html#h-10.2",
"heading": "HTML 4.01 Specification W3C 勧告. 10.2 Unordered lists (UL), ordered lists (OL), and list items (LI)",
"sub": "W3C勧告1999年12月24日",
},
{
"title": "HTML 3.2 Reference Specification. W3C Recommendation 14-Jan-1997.",
"href": "https://www.w3.org/TR/2018/SPSD-html32-20180315/",
"heading": "HTML 3.2 Reference Specification",
"sub": "W3C勧告1997年1月14日",
},
{
"title": "Hypertext Markup Language - 2.0. November 1995.",
"href": "https://www.ietf.org/rfc/rfc1866.txt",
"heading": "Hypertext Markup Language - 2.0",
"sub": "November 1995",
},
{
"title": "Hypertext Markup Language (HTML). June 1993.",
"href": "https://www.w3.org/MarkUp/draft-ietf-iiir-html-01.txt",
"heading": "Hypertext Markup Language (HTML)",
"sub": "June 1993",
},
{
"title": "MDN Web Docs. HTML <ul>: The Unordered List element.",
"href": "https://developer.mozilla.org/ja/docs/Web/HTML/Element/ul",
"heading": "<ul>: 順序なしリスト要素 - HTML: ハイパーテキストマークアップ言語 | MDN",
},
],
"version": {
"first": "HTML",
"latest": "HTML Living Standard",
},
}
}
注意: 簡易に描画する為に、各項目の後ろに
,
を付与しています。JSON の形式では、末尾の項目の後には,
は付けません。 - 最終確認日
-
2024-09-01
2.使用可能な箇所
フロー
受け入れる要素に
配置できます。
3.配置できるコンテンツ
li要素
を
配置できます。
ul
script
content
<ul>
<li>一覧項目</li>
</ul>
ul
4.属性
グローバル属性のみ、
設定できます。
ul
5.Web API
id属性を用いて
getElementById()メソッドで
要素を取得する方法がお勧めです。
ul
6.レンダリング
ul {
display: block;
margin-block-start: 1em;
margin-block-end: 1em;
padding-inline-start: 40px;
counter-reset: list-item;
list-style-type: disc;
unicode-bidi: isolate;
}
ul
ブロック
list-style-type
は、リスト項目要素のマーカーを設定します。disc
は、塗りつぶされた円形です。
unicode-bidi
は、置換されない要素のレンダリングでの Bidirectional text(双方向テキスト) に於いての期待される仕様の様です。
:is(dir, dl, menu, ol, ul) ul {
margin-block-start: 0;
margin-block-end: 0;
}
:is(dir, menu, ol, ul) ul { list-style-type: circle; }
:is(dir, menu, ol, ul) :is(dir, menu, ol, ul) ul { list-style-type: square; }
ul[type=none i] { list-style-type: none; }
ul[type=disc i] { list-style-type: disc; }
ul[type=circle i] { list-style-type: circle; }
ul[type=square i] { list-style-type: square; }
ul
属性セレクタの記述がありますが、type
<div style=
"list-style-type: "> <p>
リスト1 </p> <p>
リスト2 </p> <p>
リスト3 </p> </div>
list-style-type
リスト1
リスト2
リスト3
<ul>
<li>章<ul>
<li>節<ul>
<li>項</li>
<li>項</li>
</ul></li>
<li>節<ul>
<li>項</li>
<li>項</li>
</ul></li>
</ul></li>
<li>章<ul>
<li>節</li>
<li>節</li>
</ul></li>
</ul>
ul
- 章
- 節
- 項
- 項
- 節
- 項
- 項
- 節
- 章
- 節
- 節
<ul class=
"culSample262"> <li>
リスト1 </li> <li>
リスト2 </li> <li>
リスト3 </li> </ul>
.culSample262 {
padding-left: 1.5em;
list-style-type: none;
}
.culSample262 > * {
position: relative;
}
.culSample262 > *:before {
position: absolute;
top: 0.4em;
left: -1.0em;
content: "";
width: 10px;
height: 10px;
border-radius: 50%;
background-color: #8b6b4e;
}
マーカーをデザインしたい場合の一例です。丸の塗りつぶし
- リスト1
- リスト2
- リスト3
<ul class=
"culSample263"> <li>
リスト1 </li> <li>
リスト2 </li> <li>
リスト3 </li> </ul>
.culSample263 {
padding-left: 1.5em;
list-style-type: none;
}
.culSample263 > * {
position: relative;
}
.culSample263 > *:before {
position: absolute;
top: 0.4em;
left: -1.0em;
content: "";
width: 10px;
height: 10px;
border-radius: 50%;
border: 1px solid #8b6b4e;
}
マーカーをデザインしたい場合の一例です。丸の枠線のみ
- リスト1
- リスト2
- リスト3
<ul class=
"culSample264"> <li>
リスト1 </li> <li>
リスト2 </li> <li>
リスト3 </li> </ul>
.culSample264 {
padding-left: 1.5em;
list-style-type: none;
}
.culSample264 > * {
position: relative;
}
.culSample264 > *:before {
position: absolute;
top: 0.2em;
left: -1.0em;
content: "";
-webkit-transform: rotate(50deg);
-ms-transform: rotate(50deg);
transform: rotate(50deg);
width: 5px;
height: 10px;
border-right: 3px solid #8b6b4e;
border-bottom: 3px solid #8b6b4e;
}
マーカーをデザインしたい場合の一例です。チェックマーク
- リスト1
- リスト2
- リスト3
<ul class=
"culSample265"> <li>
リスト1 </li> <li>
リスト2 </li> <li>
リスト3 </li> </ul>
.culSample265 {
padding-left: 1.5em;
list-style-type: none;
}
.culSample265 > * {
position: relative;
}
.culSample265 > *:before {
position: absolute;
top: 0.2em;
left: -1.2em;
content: "";
width: 15px;
height: 15px;
border-radius: 2px;
border: 1px solid #8b6b4e;
}
.culSample265 > *:after {
position: absolute;
top: 0.35em;
left: -0.9em;
content: "";
-webkit-transform: rotate(50deg);
-ms-transform: rotate(50deg);
transform: rotate(50deg);
width: 3px;
height: 7px;
border-right: 2px solid #8b6b4e;
border-bottom: 2px solid #8b6b4e;
}
.culSample265 > *:hover:before {
background-color: #8b6b4e;
}
.culSample265 > *:hover:after {
border-color: #ffffff;
}
マーカーをデザインしたい場合の一例です。チェックマーク
- リスト1
- リスト2
- リスト3
7.気を付ける点
マーカーの領域
マーカーは一覧に表される項目に付けられます。既定値ではボックスの外に配置されます。マーカーの領域も事前に配慮する必要があります。
マーカーのデザイン
ul