html - Numbering with CSS Counter for Headings -


i'm trying achieve css counting headers. ex.

<h1>first heading</h1> <h2>second heading</h2> 

will converted

1. first heading 1.1 second heading 

that works fine css counter. doesn't work when h2 h3. result h3 heading add "1.0.1" instead of 1.1.1, because there no h2 heading counter h2 0.

<h1>first heading</h1> <h3>third heading (should 1.1.1)</h3> 

will converted

1. first heading 1.0.1 third heading (should 1.1.1) 

any suggestion how solve (is possible)

ps. example headings can found here http://jsfiddle.net/6xpveu0t/

please use headlines in semantically correct way.

in earlier days, people rather misused different headline-tags suit design, rather styling them correctly done today (hopefully everywhere).

in terms of semantic usage of headlines, headline 1 followed headline 2 followed headline 3. may refer w3c school headline priority.

in printed books, never find nested subchapter inside skipped chapter. therefore css counter correct.

nevertheless can include empty <h2></h2>.


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -