为什么 Edge 和 Firefox 中的
标签编号结果不同?

huangapple go评论90阅读模式
英文:

Why are there two different results for the numbering of <dl> tags in Edge and Firefox?

问题

The following snippets produce different results in Edge and Firefox:

  1. dd {
  2. display: list-item;
  3. list-style-position: inside;
  4. list-style-type: decimal;
  5. counter-increment: 1;
  6. }
  1. <ul>
  2. <li>A</li>
  3. <li>B</li>
  4. <li>C</li>
  5. </ul>
  6. <dl>
  7. <dt>Title</dt>
  8. <dd>One</dd>
  9. <dd>Two</dd>
  10. <dd>Three</dd>
  11. </dl>

In Edge, the <dl> list correctly starts with index 1. On the other hand, in Firefox, it starts from 4.

After I deleted the <ul> node above the <dl> tag, the numbering of the <dd> tags started from 1 in Firefox. I don't know why this happened.

I want the <dd> tags to start from position 1 in Firefox. What should I do?

英文:

The following snippets produce different results in Edge and Firefox:

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-css -->

  1. dd {
  2. display: list-item;
  3. list-style-position: inside;
  4. list-style-type: decimal;
  5. counter-increment: 1;
  6. }

<!-- language: lang-html -->

  1. &lt;ul&gt;
  2. &lt;li&gt;A&lt;/li&gt;
  3. &lt;li&gt;B&lt;/li&gt;
  4. &lt;li&gt;C&lt;/li&gt;
  5. &lt;/ul&gt;
  6. &lt;dl&gt;
  7. &lt;dt&gt;Title&lt;/dt&gt;
  8. &lt;dd&gt;One&lt;/dd&gt;
  9. &lt;dd&gt;Two&lt;/dd&gt;
  10. &lt;dd&gt;Three&lt;/dd&gt;
  11. &lt;/dl&gt;

<!-- end snippet -->

In Edge, the &lt;dl&gt; list correctly starts with index 1. On the other hand, that of Firefox is 4.

After I deleted the &lt;ul&gt; node above the &lt;dl&gt; tag, the numbering of the &lt;dd&gt; tags started from 1. I don't know why this happened.

I want the &lt;dd&gt; tags to start from position 1 in Firefox. What should I do?

答案1

得分: 1

"Looks like Firefox is using the same counter for LI in UL, and DD in DL - but doesn't reset it on the DL element level.

Try adding dl { counter-reset: list-item; }"

英文:

Looks like Firefox is using the same counter for LI in UL, and DD in DL - but doesn't reset it on the DL element level.

Try adding dl { counter-reset: list-item; }

huangapple
  • 本文由 发表于 2023年5月22日 16:04:42
  • 转载请务必保留本文链接:https://go.coder-hub.com/76304139.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定