How do I create a tab in HTML and CSS?
Sarah Cherry
Published Feb 09, 2026
How do I create a tab in HTML and CSS?
Learn how to create tabs with CSS and JavaScript.
- Tabs. Tabs are perfect for single page web applications, or for web pages capable of displaying different subjects:
- Create Toggleable Tabs. Step 1) Add HTML:
- Fade in Tabs: If you want to fade in the tab content, add the following CSS:
- Show a tab by default.
- Close a tab.
How do I create a tab in HTML?
The tab character can be inserted by holding the Alt and pressing 0 and 9 together.
How do I make a horizontal tab in HTML?
To the first button, add a tab-btn-active class. The active class will come in handy when specifying in the CSS and JavaScript what happens to the tab when the tab button is clicked. Add HTML, CSS, and JavaScript as the names of the buttons, respectively. Add a data for-tab=’ ‘ attribute to each of these buttons now.
How do you code a tab?
The Unicode code points for the (horizontal) tab character, and the more rarely used vertical tab character are copied from ASCII:
- U+0009 (CHARACTER TABULATION, horizontal tabulation (HT), tab)
- U+000B (LINE TABULATION, vertical tabulation (VT))
What is the tab tag in HTML?
The tab-size property specifies the width of a tab character. In HTML, the tab character is usually displayed as a single space-character, except for some elements, like and , and the result of the tab-size property will only be visible for those elements.
What is the HTML code for tab space?
Adding Tab Space in HTML Unlike with HTML space, there is no particular HTML tab character you could use. You could technically use the entity as the tab is character 9 in the ASCII. Unfortunately, HTML parsers will simply collapse it into a single space due to the whitespace collapse principle.
How do I create a vertical tab in HTML?
Example
- float: left; border: 1px solid #ccc; background-color: #f1f1f1; width: 30%; height: 300px;
- display: block; background-color: inherit; color: black; padding: 22px 16px; width: 100%; border: none; outline: none;
- float: left; padding: 0px 12px; border: 1px solid #ccc; width: 70%; border-left: none; height: 300px;
How do you add a vertical tab?
To access the vertical tab sidebar, click the “Turn on vertical tabs” button at the left side of Edge’s tab bar. You’ll see a tab sidebar at the left side of your screen. By default, it will show small icons representing each tab you have open, using the favicon or each web page you have open.
Is there tab in HTML?
Adding Tab Space in HTML Unlike with HTML space, there is no particular HTML tab character you could use. You could technically use the entity as the tab is character 9 in the ASCII. There used to be a special tab element.
How do you tag in CSS?
There are three main methods of accessing or referring to HTML elements in CSS:
- By referring to the HTML element by its HTML tag name, e.g. p to refer to the paragraph HTML tag –
- By using an ID, e.g.
Some text
- By using a class, e.g.
Some text
What are the 5 basic HTML tags?
List of HTML 5 Tags
| Tag | Description |
|---|---|
| It defines a header for a section. | |
| It defines the main content of a document. | |
| It specifies the marked or highlighted content. | |
| It defines a command that the user can invoke from a popup menu. |