- Расстояние между буквами, строками, ширина табуляции в CSS
- Красная строка
- Расстояние между буквами
- Ширина пробелов
- Ширина табуляции
- Ширина букв
- CSS tab-size Property
- Browser Support
- CSS Syntax
- Property Values
- CSS tab-size Property
- Syntax
- Example of the tab-size property:
- Result
- Values
- Browser support
- Practice Your Knowledge
- The tab-size property is only visible for
- Customizing CSS Tabs
- Syntax for customizing CSS tabs
- Browser support
- Mobile browser support
- Related Posts
- tab-size¶
- Демо¶
- Синтаксис¶
- Значения¶
- Спецификация¶
- Поддержка браузерами¶
- Пример¶
Расстояние между буквами, строками, ширина табуляции в CSS
Демонстрация возможностей CSS для настройки расстояний между буквами, строками, табуляции и других свойств шрифтов.
Красная строка
Свойство text-indent устанавливает сдвиг первой строки, цвет первой буквы можно определить свойством :first-letter.
Расстояние между буквами
Свойство letter-spacing устанавливает интервал между символами. В качестве значений принимаются единицы длины (px, in, pt, em, ex), допустимо отрицательное значение. Лучшая точность получается при использовании em.
Ширина пробелов
Word-spacing задает интервал между словами, значение можно указать в px, in, pt, em, ex.
Ширина табуляции
Свойство tab-size устанавливает ширину табуляции в , , и других элементах со свойством white-space: pre . В качестве значения используется количество символов (по умолчанию 8) или единицы длины.
Свойство пока ещё не стандартизировано W3C, но поддерживается современными браузерами.
Ширина букв
Свойство font-stretch задаёт ширину символов в шрифте, работает только со шрифтами, у которых есть поддержка разных начертаний. Значения задаются константами или процентами:
normal | 100% | Обычная ширина |
semi-condensed | 87.5% | Узковатая ширина |
condensed | 75% | Узкая ширина |
extra-condensed | 62.5% | Очень узкая ширина |
ultra-condensed | 50% | Самая узкая ширина |
semi-expanded | 112.5% | Широковатая ширина |
expanded | 125% | Средне-большая ширина |
extra-expanded | 150% | Очень большая ширина |
ultra-expanded | 200% | Самая большая ширина |
CSS tab-size Property
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.
Default value: | 8 |
---|---|
Inherited: | yes |
Animatable: | no. Read about animatable |
Version: | CSS3 |
JavaScript syntax: | object.style.tabSize=»16″ Try it |
Browser Support
The numbers in the table specify the first browser version that fully supports the property.
Numbers followed by -moz- or -o- specify the first version that worked with a prefix.
Note: No browser is currently supporting the length unit value.
CSS Syntax
Property Values
Value | Description | Play it |
---|---|---|
number | The number of space-characters to be displayed for each tab-character. Default value is 8 | Demo ❯ |
length | The length of a tab-character. This property value is not supported in any of the major browsers | |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
CSS tab-size Property
The tab-size property is used to set the width of the tab character (U+0009) displaying on the page.
The tab-size property is one of the CSS3 properties. It is only visible for and HTML tags.
For maximum browser compatibility -moz- for Firefox and -o- for Opera extensions are used with this property.
Initial Value | 8 |
Applies to | Block containers. |
Inherited | Yes. |
Animatable | No. |
Version | CSS3 |
DOM Syntax | object.style.tabSize = «20»; |
Syntax
tab-size: number | length | initial | inherit;
Example of the tab-size property:
html> html> head> title>Title of the document title> style> .tab1 < -moz-tab-size: 5; /* Firefox */ -o-tab-size: 5;/* Opera 10.6-12.1 */ tab-size: 5; > .tab2 < -moz-tab-size: 20;/* Firefox */ -o-tab-size: 20;/* Opera 10.6-12.1 */ tab-size: 20; > style> head> body> h2>Tab-size property example h2> pre class="tab1"> Lorem ipsum is a. pre> pre class="tab2"> Lorem ipsum is a. pre> body> html>
Result
In the given example, the tab-size of the first element is 5, the one of the second element is 20.
Values
Value | Description | Play it |
---|---|---|
number | Sets the number of the space characters in the tab. Negative values are invalid. The default value is 8. | Play it » |
length | Sets the width of the tab. Negative values are invalid. This value is not supported by major browsers. | |
initial | Makes the property use its default value. | Play it » |
inherit | Inherits the property from its parent element. |
Browser support
Practice Your Knowledge
The tab-size property is only visible for
Customizing CSS Tabs
By using the CSS tab-size property, you can define a custom size for the tab character:
Note: due to the whitespace collapse principle, CSS tabs or multiple spaces can only be displayed in preformatted text.
- Easy to use with a learn-by-doing approach
- Offers quality content
- Gamified in-browser coding experience
- The price matches the quality
- Suitable for learners ranging from beginner to advanced
- Free certificates of completion
- Focused on data science skills
- Flexible learning timetable
- Simplistic design (no unnecessary information)
- High-quality courses (even the free ones)
- Variety of features
- Nanodegree programs
- Suitable for enterprises
- Paid Certificates of completion
Syntax for customizing CSS tabs
The CSS tab-size property only takes one value that define the width of the tab character:
You can specify it in two ways:
- Length units can be used to define exact width
- A unitless number defines how many spaces the tab will be equal to in width
Browser support
Chrome
Edge
Firefox
IE
Opera
Safari
Mobile browser support
Chrome
Firefox
Opera
Safari
CSS
CSS Typography
CSS Backgrounds & Colors
CSS Effects
CSS Layout
CSS Responsive
CSS Element Styling
CSS References
CSS Properties
Best-rated MOOCs to Learn Programming:
Related Posts
CSS Properties: A Reference Guide
Learn about common CSS properties and find all CSS property descriptions in one place with this comprehensive and easy to understand CSS properties list.
CSS Link Color Guide With Examples
CSS link color: how to easily change CSS link color? Learn to remove underline from link in CSS made simple. Check out our CSS link color examples.
How to Add an HTML Tab and Avoid Whitespace Collapse
There are multiple ways to add an HTML tab. See them all plus alternatives in this easy-to-follow HTML tab tutorial & learn to avoid whitespace collapse.
tab-size¶
Свойство tab-size используется для настройки ширины символа табуляции ( U+0009 ).
Демо¶
- letter-spacing
- text-decoration
- text-decoration-color
- text-decoration-line
- text-decoration-style
- text-decoration-thickness
- text-decoration-skip
- text-decoration-skip-ink
- text-emphasis
- text-emphasis-color
- text-emphasis-position
- text-emphasis-style
- text-indent
- text-rendering
- text-shadow
- text-underline-position
- text-transform
- white-space
- word-spacing
Синтаксис¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/* значения */ tab-size: 4; tab-size: 0; /* значения */ tab-size: 10px; tab-size: 2em; /* Глобальные значения */ tab-size: inherit; tab-size: initial; tab-size: revert; tab-size: revert-layer; tab-size: unset;
Значения¶
Спецификация¶
Поддержка браузерами¶
Пример¶
pre tab-size: 4; /* Установит размер таба в 4 пробела */ > pre tab-size: 0; /* Удалит отступ */ > pre tab-size: 2; /* Установит размер таба в 2 пробела */ >