<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://script.spoken-tutorial.org/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://script.spoken-tutorial.org/index.php?action=history&amp;feed=atom&amp;title=CSS%2FC4%2FCounters-in-CSS%2FEnglish</id>
		<title>CSS/C4/Counters-in-CSS/English - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://script.spoken-tutorial.org/index.php?action=history&amp;feed=atom&amp;title=CSS%2FC4%2FCounters-in-CSS%2FEnglish"/>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=CSS/C4/Counters-in-CSS/English&amp;action=history"/>
		<updated>2026-04-30T02:20:00Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.23.17</generator>

	<entry>
		<id>https://script.spoken-tutorial.org/index.php?title=CSS/C4/Counters-in-CSS/English&amp;diff=54638&amp;oldid=prev</id>
		<title>Nehasolanki: Created page with &quot;'''Title of the script: '''Counters in CSS  '''Author:''' Neha Solanki  '''Domain Reviewer: '''Ankita Maske, Om Prakash Soni  '''Novice Reviewer:''' Madhuri Ganapathi  '''Keyw...&quot;</title>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=CSS/C4/Counters-in-CSS/English&amp;diff=54638&amp;oldid=prev"/>
				<updated>2021-01-06T01:45:32Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;#039;&amp;#039;&amp;#039;Title of the script: &amp;#039;&amp;#039;&amp;#039;Counters in CSS  &amp;#039;&amp;#039;&amp;#039;Author:&amp;#039;&amp;#039;&amp;#039; Neha Solanki  &amp;#039;&amp;#039;&amp;#039;Domain Reviewer: &amp;#039;&amp;#039;&amp;#039;Ankita Maske, Om Prakash Soni  &amp;#039;&amp;#039;&amp;#039;Novice Reviewer:&amp;#039;&amp;#039;&amp;#039; Madhuri Ganapathi  &amp;#039;&amp;#039;&amp;#039;Keyw...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;'''Title of the script: '''Counters in CSS&lt;br /&gt;
&lt;br /&gt;
'''Author:''' Neha Solanki&lt;br /&gt;
&lt;br /&gt;
'''Domain Reviewer: '''Ankita Maske, Om Prakash Soni&lt;br /&gt;
&lt;br /&gt;
'''Novice Reviewer:''' Madhuri Ganapathi&lt;br /&gt;
&lt;br /&gt;
'''Keywords: '''CSS, HTML, Web Page, Web Design, Web Technology, Video Tutorial, Spoken Tutorial, CSS Counters, CSS counter-reset, CSS counter-increment, CSS content, CSS counter() or counters() function&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|  | '''Visual Cue'''&lt;br /&gt;
|  | '''Narration'''&lt;br /&gt;
|-&lt;br /&gt;
|  | Slide: Title&lt;br /&gt;
|  | Welcome to the spoken tutorial on '''Counters in CSS'''. &lt;br /&gt;
|-&lt;br /&gt;
|  | Slide: Learning Objectives&lt;br /&gt;
|  | In this tutorial we will learn about:&lt;br /&gt;
&lt;br /&gt;
* '''Counters '''in''' CSS '''and&lt;br /&gt;
* Their properties and usage&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  | Slide: &lt;br /&gt;
&lt;br /&gt;
System Requirements&lt;br /&gt;
&lt;br /&gt;
|  | This tutorial is recorded using,&lt;br /&gt;
&lt;br /&gt;
* '''Ubuntu Linux OS v 18.04 '''&lt;br /&gt;
* '''CSS3'''&lt;br /&gt;
* '''HTML5'''&lt;br /&gt;
* '''gedit Text Editor '''and&lt;br /&gt;
* '''Firefox web browser'''&lt;br /&gt;
&lt;br /&gt;
However you may use any other '''editor''' or '''browser''' of your choice.&lt;br /&gt;
|-&lt;br /&gt;
|  | Slide: Prerequisite &lt;br /&gt;
&lt;br /&gt;
https://spoken-tutorial.org&lt;br /&gt;
|  | To practise this tutorial, you should know to use '''HTML''' and '''CSS'''.&lt;br /&gt;
&lt;br /&gt;
If not, please go through the '''HTML''' and '''CSS '''tutorials on this website.&lt;br /&gt;
|-&lt;br /&gt;
|  | Slide: Code Files&lt;br /&gt;
|  | The files used in this tutorial are available in the '''Code Files''' link on this tutorial page.&lt;br /&gt;
&lt;br /&gt;
Please download and extract them.&lt;br /&gt;
&lt;br /&gt;
Make a copy and then use them while practising.&lt;br /&gt;
|-&lt;br /&gt;
|  | Slide: Counters&lt;br /&gt;
|  | &lt;br /&gt;
* '''Counters''' are variables used for numbering '''elements''' automatically in the '''webpage.'''&lt;br /&gt;
* They are incremented by '''CSS''' rules.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  | Slide: Counter Property&lt;br /&gt;
|  | The properties used for '''counters''' are:&lt;br /&gt;
&lt;br /&gt;
* '''counter-reset '''&lt;br /&gt;
* '''counter-increment'''&lt;br /&gt;
* '''content'''&lt;br /&gt;
* '''counter() '''or''' counters() function'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  | Slide: counter-reset&lt;br /&gt;
|  | &lt;br /&gt;
* '''Counter-reset''' property is used to create a '''counter''' or reset a '''counter''' value.&lt;br /&gt;
* By default, the '''counter''' value is initialized to '''zero'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  | Slide: counter-increment&lt;br /&gt;
|  | &lt;br /&gt;
* '''Counter-increment''' property is used to increment '''counter '''values.&lt;br /&gt;
* It is useful for automatically increasing step values.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  | Slide: content&lt;br /&gt;
|  |&lt;br /&gt;
* '''Content''' property is used to generate content for an '''element'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  | Slide: counter() or counters() function&lt;br /&gt;
|  | &lt;br /&gt;
* '''counter() '''or''' counters() function '''assigns the '''counter''' value to an '''element'''.&lt;br /&gt;
&lt;br /&gt;
Let us understand these through examples.&lt;br /&gt;
|-&lt;br /&gt;
|  | Open my-css''' '''folder&lt;br /&gt;
|  | Go to the practice folder '''my-css.'''&lt;br /&gt;
|-&lt;br /&gt;
|  | Point to Mycounter.html in my-css folder&lt;br /&gt;
|  | For this demonstration, I’m using the file '''Mycounter.html'''.&lt;br /&gt;
&lt;br /&gt;
The same is available in the '''Code files''' link for practice.&lt;br /&gt;
|-&lt;br /&gt;
|  | Open Mycounter.html in gedit&lt;br /&gt;
|  | Open the file '''Mycounter.html''' in the '''text editor.'''&lt;br /&gt;
&lt;br /&gt;
I have opened it in the '''gedit Text Editor.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  | [gedit - Mycounter.html]&lt;br /&gt;
&lt;br /&gt;
Highlight:&lt;br /&gt;
&lt;br /&gt;
All code&lt;br /&gt;
|  | This '''HTML''' file has one '''h1 heading '''- '''Welcome to Farmer's Market.'''&lt;br /&gt;
&lt;br /&gt;
This is followed by three '''h2 headings''', having their respective content.&lt;br /&gt;
|-&lt;br /&gt;
|  | Switch to my-css folder&lt;br /&gt;
|  | Switch to the '''my-css''' folder.&lt;br /&gt;
|-&lt;br /&gt;
|  | Open counterstyle.css&lt;br /&gt;
|  | Now open the file '''counterstyle.css''' in any''' text editor.'''&lt;br /&gt;
&lt;br /&gt;
I have opened it in the '''gedit Text Editor.'''&lt;br /&gt;
|-&lt;br /&gt;
|  | [gedit - counterstyle.css]&lt;br /&gt;
&lt;br /&gt;
Highlight: All code&lt;br /&gt;
|  | Here, I have already defined some properties for '''body '''and '''h1 heading.'''&lt;br /&gt;
|-&lt;br /&gt;
|  | Open Mycounter.html in firefox&lt;br /&gt;
|  | Switch to the '''my-css''' folder.&lt;br /&gt;
&lt;br /&gt;
Now open the file '''Mycounter.html''' in a '''web browser'''.&lt;br /&gt;
&lt;br /&gt;
I have opened it in the''' Firefox web browser'''.&lt;br /&gt;
|-&lt;br /&gt;
|  | [Firefox] &lt;br /&gt;
&lt;br /&gt;
Highlight the page&lt;br /&gt;
|  | Observe the page.&lt;br /&gt;
&lt;br /&gt;
In this page, we can see three '''h2 headings:'''&lt;br /&gt;
&lt;br /&gt;
'''Vegetables''',''' Fruits''',''' Dry Fruits.'''&lt;br /&gt;
&lt;br /&gt;
Now I will apply '''counter '''properties to these '''headings'''.&lt;br /&gt;
|-&lt;br /&gt;
|  | Switch to counterstyle.css&lt;br /&gt;
|  | Switch to the '''counterstyle.css''' file.&lt;br /&gt;
|-&lt;br /&gt;
|  | [gedit - counterstyle.css]&lt;br /&gt;
&lt;br /&gt;
Type:&lt;br /&gt;
&lt;br /&gt;
counter-reset: countval;&lt;br /&gt;
|  | First I will create a '''counter'''.&lt;br /&gt;
&lt;br /&gt;
Inside the '''body tag''', next to the '''background-color''' property, type the code as shown.&lt;br /&gt;
&lt;br /&gt;
A''' Counter''' named '''countval''' is created.&lt;br /&gt;
|-&lt;br /&gt;
|  | [gedit - counterstyle.css]&lt;br /&gt;
&lt;br /&gt;
Type:&lt;br /&gt;
&lt;br /&gt;
h2::before {counter-increment: countval;&lt;br /&gt;
&lt;br /&gt;
content: &amp;quot;Category &amp;quot; counter(countval) &amp;quot;. &amp;quot;;}&lt;br /&gt;
|  | Now I will assign this '''counter''' to '''h2 heading.'''&lt;br /&gt;
&lt;br /&gt;
Next to the '''h1 tag''', type the code as shown.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  | [gedit - counterstyle.css]&lt;br /&gt;
&lt;br /&gt;
Highlight: h2::before &lt;br /&gt;
|  | '''Counter'''s will be displayed before the '''heading''' content.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  | [gedit - counterstyle.css]&lt;br /&gt;
&lt;br /&gt;
Highlight:&lt;br /&gt;
&lt;br /&gt;
counter-increment: countval;&lt;br /&gt;
|  | By using '''counter-increment''' property I have incremented the '''countval counter.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  | [gedit - counterstyle.css]&lt;br /&gt;
&lt;br /&gt;
Highlight:&lt;br /&gt;
&lt;br /&gt;
content: &amp;quot;Category &amp;quot; &lt;br /&gt;
&lt;br /&gt;
&amp;quot;. &amp;quot;;&lt;br /&gt;
&lt;br /&gt;
counter(countval)&lt;br /&gt;
|  | Here '''content''' property will generate the word “'''category'''” first. &lt;br /&gt;
&lt;br /&gt;
Then it will generate the '''counter''' value followed by the '''dot symbol'''.&lt;br /&gt;
&lt;br /&gt;
Here '''countval''' is assigned to the '''counter function'''.&lt;br /&gt;
|-&lt;br /&gt;
|  | Press Ctrl + S&lt;br /&gt;
|  | Save the file.&lt;br /&gt;
|-&lt;br /&gt;
|  | Switch to firefox&lt;br /&gt;
|  | Switch to the '''browser''' and refresh the page.&lt;br /&gt;
|-&lt;br /&gt;
|  | [Firefox] &lt;br /&gt;
&lt;br /&gt;
Highlight the output&lt;br /&gt;
|  | Observe the output.&lt;br /&gt;
&lt;br /&gt;
Now, '''Category 1. Category 2. Category 3.'''&lt;br /&gt;
&lt;br /&gt;
are added before the '''content''' of the '''headings'''.&lt;br /&gt;
&lt;br /&gt;
Here the word “'''Category'''” is the '''content''' added to the '''counter.'''&lt;br /&gt;
&lt;br /&gt;
'''1, 2 '''and''' 3''' are the '''counters'''.&lt;br /&gt;
|-&lt;br /&gt;
|  | Slide: Nested Counters&lt;br /&gt;
|  | &lt;br /&gt;
* '''Nested counter''' means a '''counter''' within a '''counter'''.&lt;br /&gt;
&lt;br /&gt;
Let us try this.&lt;br /&gt;
|-&lt;br /&gt;
|  | Switch to counterstyle.css&lt;br /&gt;
|  | Switch to the '''counterstyle.css''' file.&lt;br /&gt;
|-&lt;br /&gt;
|  | Point to''' h1''' heading.&lt;br /&gt;
&lt;br /&gt;
Highlight '''h1''' heading.&lt;br /&gt;
|  | First I will create a '''counter''' for '''h1 heading “Welcome to Farmer's Market”'''&lt;br /&gt;
&lt;br /&gt;
Then I will create''' h2 heading counters '''within the '''h1 heading counter.'''&lt;br /&gt;
|-&lt;br /&gt;
|  | [gedit - counterstyle.css]&lt;br /&gt;
&lt;br /&gt;
Update:&lt;br /&gt;
&lt;br /&gt;
counter-reset: countmain;&lt;br /&gt;
|  | For this, create a '''counter''' named '''countmain''' for '''h1 heading'''.&lt;br /&gt;
&lt;br /&gt;
Inside the''' body tag, '''update the '''counter-reset '''property''' '''as shown.&lt;br /&gt;
|-&lt;br /&gt;
|  | [gedit - counterstyle.css]&lt;br /&gt;
&lt;br /&gt;
Type:&lt;br /&gt;
&lt;br /&gt;
counter-reset: countval;&lt;br /&gt;
|  | Now I will create a '''counter''' named '''countval''' for '''h2 heading''' inside '''h1 heading'''.&lt;br /&gt;
&lt;br /&gt;
Inside the''' h1 tag, '''next to the''' text-align '''property''',''' type the''' '''code''' '''as shown.&lt;br /&gt;
|-&lt;br /&gt;
|  | [gedit - counterstyle.css]&lt;br /&gt;
&lt;br /&gt;
Type:&lt;br /&gt;
&lt;br /&gt;
h1::before { counter-increment: countmain;&lt;br /&gt;
&lt;br /&gt;
content: counter(countmain) &amp;quot;. &amp;quot;;}&lt;br /&gt;
|  | I will assign the '''counter''' '''countmain '''to '''h1 heading.'''&lt;br /&gt;
&lt;br /&gt;
Next to '''h1 tag''', type the code as shown here.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  | [gedit - counterstyle.css]&lt;br /&gt;
&lt;br /&gt;
Update:&lt;br /&gt;
&lt;br /&gt;
h2::before { counter-increment: countval;&lt;br /&gt;
&lt;br /&gt;
content: counter(countmain) &amp;quot;.&amp;quot; counter(countval) &amp;quot; &amp;quot;;}&lt;br /&gt;
|  | Now I will assign the '''counter''' '''countval '''to '''h2 heading.'''&lt;br /&gt;
&lt;br /&gt;
Update the '''h2::before property''' as shown.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  | Press Ctrl + S&lt;br /&gt;
|  | Save the file.&lt;br /&gt;
|-&lt;br /&gt;
|  | Switch to firefox&lt;br /&gt;
|  | Switch to the '''browser''' and refresh the page.&lt;br /&gt;
|-&lt;br /&gt;
|  | [Firefox] &lt;br /&gt;
&lt;br /&gt;
Highlight the output&lt;br /&gt;
|  | Observe the output.&lt;br /&gt;
&lt;br /&gt;
'''Counter''' '''“1. '''” is displayed before the '''heading''' '''“Welcome to Farmer's Market”.'''&lt;br /&gt;
&lt;br /&gt;
'''Counter''' '''“1. '''” is displayed as a main '''counter.'''&lt;br /&gt;
&lt;br /&gt;
The sub-counters for '''h2 headings''' are displayed as:&lt;br /&gt;
&lt;br /&gt;
'''1.1 Vegetables'''&lt;br /&gt;
&lt;br /&gt;
'''1.2 Fruits'''&lt;br /&gt;
&lt;br /&gt;
'''1.3 Dry Fruits'''&lt;br /&gt;
&lt;br /&gt;
In this manner, you can add '''counters''' to your '''webpage, '''as per your requirements.&lt;br /&gt;
|-&lt;br /&gt;
|  | Only narration&lt;br /&gt;
|  | With this we have come to the end of this tutorial. &lt;br /&gt;
&lt;br /&gt;
Let us summarize.&lt;br /&gt;
|-&lt;br /&gt;
|  | Slide: Summary &lt;br /&gt;
|  | In this tutorial, we have learnt about:&lt;br /&gt;
&lt;br /&gt;
* '''Counters '''in''' CSS '''and&lt;br /&gt;
* Their properties and usage&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  | Slide: Assignment&lt;br /&gt;
| As an assignment&lt;br /&gt;
&lt;br /&gt;
* Open the file '''webpage.html''' which you have created earlier.&lt;br /&gt;
* Add three '''h3 headings.'''&lt;br /&gt;
* Open the file '''styles.css '''which you have created earlier.&lt;br /&gt;
* Set '''counter '''for''' h3 headings'''&lt;br /&gt;
* Link the '''styles.css''' file to '''webpage.html''' file&lt;br /&gt;
&lt;br /&gt;
* Observe the output&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  | Slide: About Spoken Tutorial project&lt;br /&gt;
|  | The video at the following link summarises the Spoken Tutorial project.&lt;br /&gt;
&lt;br /&gt;
Please download and watch it.&lt;br /&gt;
|-&lt;br /&gt;
|  | Slide: About Workshop&lt;br /&gt;
|  | The Spoken Tutorial Project team conducts workshops and gives certificates.&lt;br /&gt;
&lt;br /&gt;
For more details, please write to us.&lt;br /&gt;
|-&lt;br /&gt;
|  | Slide: Forum questions&lt;br /&gt;
|  | Please post your timed queries on this forum.&lt;br /&gt;
|-&lt;br /&gt;
|  | Slide: Acknowledgement&lt;br /&gt;
|  | Spoken Tutorial project is funded by Ministry of Education (MoE), Govt. of India.&lt;br /&gt;
|-&lt;br /&gt;
|  | Slide: Thanks&lt;br /&gt;
|  | This is Neha Solanki from IIT Bombay.&lt;br /&gt;
&lt;br /&gt;
Thank you for watching.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Nehasolanki</name></author>	</entry>

	</feed>