Hello dear readers of the blog site. In this article, we continue to explore the basics of CSS styling and take a look at the vertical-align, text-align, text-indent, and some others properties for styling html text.
Aligning text with CSS
Let's start with the style attributes that control the rendering of text in block elements. Let's start with the text-align property, which is actually a replacement for the align attribute (used to align the content of html elements such as p paragraphs).
Style property text-align asks horizontal text alignmentand has only four possible values:
The available values \u200b\u200bfor this rule determine the alignment, respectively: left - to the left, right - to the right, center - to the center, and justify - to the width of the page (simultaneously left and right by increasing the distance between words). For example, the text in this article is aligned to the width of the page (if you notice it has even borders on both left and right) using the text-align: justify rule.
By default, horizontal alignment is left-aligned, so you don't need to specifically specify text-align: left if no other alignment has been specified in the parent elements.
Examples of using the property:
Next CSS property text-ident asks indent for the red line, for example for the text in the paragraph tag p. This rule, like text-align, only applies to block elements. Syntax:
Absolute and relative indentation values \u200b\u200bare allowed here. Absolute values \u200b\u200b(px - pixels, em, ex, etc.) can be specified either with a plus or minus sign. The relative value is usually given as a percentage (%). The relative value is calculated from the width of the text area. So, the css rule text-indent: 50% will set the red line equal to half the length of this line itself. By default, the "red line" indent is zero. Example:
Next, let's look at vertical alignment - the property vertical-align... This property is already applicable for all html elements and for almost all means the alignment of inline elements with text relative to their baseline. Except for the table tags td and th, in which all content will be vertically aligned. Syntax:
Let's consider each value in more detail:
- baseline - alignment of a piece of text with the baseline of the parent element. This is the default;
- sub - a piece of text is displayed as a subscript or subscript for the parent element;
- super - a piece of text is displayed as a superscript or superscript for the parent element;
- top - aligns a piece of text to the top of the parent element;
- text-top - aligns the fragment to the top edge of the parent element's text;
- middle - aligns the center of the text fragment to the center of the parent element;
- bottom - aligns a piece of text to the bottom of the parent element;
- text-bottom - alignment of the fragment to the bottom edge of the parent element's text;
The figure below shows the behavior of test fragments with different values \u200b\u200bof the vertical-align property in Internet Explorer 11:
In addition to the above values, you can specify numeric values. For example, the CSS rule vertical-align: 0 would mean the same as writing vertical-align: baseline. And the vertical-align: 10px rule will move the text up 10 pixels from the baseline. To move the text down, the value must be specified with a minus.
The offset can also be specified in relative units, such as em and ex, or as a percentage.
To vertically align the contents of table cells in vertical-align, use the following values:
- top - to align content to the top border of the cell;
- bottom - to align content to the bottom of the cell;
- middle - to align to the center of the cell (used by default).
To achieve the desired result, you usually have to experiment with different values \u200b\u200bfor the vertical-align style property. Numerous possible values \u200b\u200bgive very different results in different cases.
White-space and word-wrap options to control line breaks
Next in line is the white-space parameter, which is responsible for displaying whitespace characters on the html page.
As we know, by default, the browser concatenates all consecutive whitespace characters: spaces, line breaks and tabs, into one space. An exception pre tag, the text placed in it is displayed as is, with all spaces.
The white-space property has the following syntax:
It is clear that the normal value is used by default and leaves everything as described above, all consecutive spaces are combined into one and line breaks are set automatically.
Using the value "pre" would be the same as using the tag "pre". The browser will render the page with any extra spaces and hyphens as added by the developer. If a line of text is too long, a horizontal scroll bar will be added.
The nowrap value prevents the browser from wrapping lines and the text is displayed on a single line. The only thing, adding the "br" tag will allow you to wrap the text on a new line.
The pre-wrap value preserves all sequences of spaces and line breaks, but if the line does not fit into the specified area, the browser automatically wraps the text on a new line.
Well, the pre-line value converts spaces to one space, line feeds are saved, and the browser may break lines that are too long to avoid horizontal scrolling.
Usage example:
Next, consider word-wrap parameter, which will tell you whether or not to wrap long words that do not fit in the given area. This property is not often used, but sometimes you can't do without it:
word-wrap: normal | break-word
The normal value tells the browser to break text only at spaces, and this is normal browser behavior. And the break-word value allows the browser to insert line breaks inside words. Example:
Text shadow parameters - text-shadow property
For fans of various embellishments in the CSS3 standard, it became possible to set a shadow for text. Proper use of the text-shadow property can visibly animate a web page. Syntax:
The value none cancels the shadowing of the text and is set by default.
Shade color is set in any available CSS format and is an optional parameter. By default, the shadow color is the same as the text color.
Horizontal offset of the shadow can be specified in any unit of measure supported by CSS. A positive value will position the shadow to the right of the text, and a negative value to the left. A value of zero will position the shadow directly below the text and only makes sense if the shadow is blurred.
Vertical offset of the shadow also can be set in any unit of measure supported by CSS. A positive value will move the shadow below the text; a negative value will move it above. A value of zero will position the shadow directly below the text.
In any unit of measurement, and shadow blur radius... The higher the value, the wider the shadow becomes and the more it smoothes. If this parameter is not set, the blur value is assumed to be zero. Since the anti-aliasing algorithm is usually different for different browsers, the appearance of the shadow may differ slightly depending on the browser.
Module Css text describes the CSS functions that control the translation of source text into formatted text and line wrapping. Various CSS properties provide control over case conversion, handling of spaces, hyphenation and wrapping rules for text and lines, alignment, spacing, and indentation.
The basic unit of text is a symbol. However, since writing systems are not always as simple as the mainstream English alphabet, what a symbol actually is depends on the context in which the term is used. For example, in the Korean writing system, each square representation of a syllable (for example, 한 \u003d han) can be considered a symbol. However, a square symbol does indeed consist of several letters, each representing a phoneme (for example, ㅎ \u003d h, ㅏ \u003d a, ㄴ \u003d n), and each of them can also be considered a symbol.
1. Transforming text: the text-transform property
The text-transform property will style the text. It does not affect the underlying content, and it should not affect the content of a plain text copy and paste operation.
The property is inherited.
Syntax
Text-transform: none; text-transform: capitalize; text-transform: uppercase; text-transform: lowercase; text-transform: inherit; text-transform: initial;
2. Handling spaces and line breaks: the white-space property
The white-space property handles spaces between words and line breaks within an element.
The property is inherited.
white-space | |
---|---|
Values: | |
normal | Default value. Only one space is inserted between words, additional spaces are discarded. The text is wrapped only if necessary. |
nowrap | Prevents line breaks except when applied . |
pre | Spaces in the text are not ignored, the browser displays extra spaces and line breaks. |
pre-wrap | Preserves spaces in the text by making line breaks where necessary. |
pre-line | Removes extra spaces except in cases . |
break-spaces | The behavior is identical to pre-wrap, except that: any sequence of non-removable whitespace always takes up space, including at the end of a line; line break exists after each non-removable space, including between spaces. |
initial | |
inherit |
Syntax
White-space: normal; white-space: nowrap; white-space: pre; white-space: pre-wrap; white-space: pre-line; white-space: break-spaces; white-space: inherit; white-space: initial;
3. Setting tabs: the tab-size property
The tab-size property is used to change the amount of indentation obtained with the Tab key. Property values \u200b\u200bare ignored when one of the three pre-line, normal, or nowrap values \u200b\u200bof the white-space property is set.
Only works for elements
The property is inherited.
Syntax
Tab-size: 0; tab-size: 10px; tab-size: inherit; tab-size: initial;
4. Line break and word boundaries
When line-level content is broken into lines, it is broken into linear blocks. This splitting is called a line break.
When a line breaks due to explicit line break controls like newline or tag
, start or end of a block is a forced line break.
If a line breaks due to content wrapping when the browser creates optional line breaks to fit the content, it is soft wrapping.
4.1. Letter break rules: the word-break property
The word-break property defines the possibilities for soft wrap between letters, i.e. when it is permissible to split lines of text. In particular, it controls whether soft hyphenation exists between adjacent typographic letter units and / or numbers. This does not affect the rules governing soft hyphenation created by spaces.
The property is inherited.
Syntax
Word-break: normal; word-break: break-all; word-break: keep-all; word-break: inherit; word-break: initial;
4.2. Line break: line-break
The line-break property defines the rules for line wrapping applied within an element, specifically how the wrapping interacts with punctuation marks and symbols.
The property is inherited.
line-break | |
---|---|
Values: | |
auto | The browser defines a set of line break constraints to use, which can vary based on line length, such as using a less stringent set of line break rules for short lines. Default value. |
loose | Splits text using the least restrictive set of line wrapping rules. Typically used for short lines, such as in newspapers. |
normal | Splits text using the most common set of line wrapping rules. |
strict | Breaks up text using a strict set of line break rules. |
initial | Sets the property value to its default value. |
inherit | Inherits the property value from the parent element. |
Syntax
Line-break: auto; line-break: loose; line-break: normal; line-break: strict; line-break: inherit; line-break: initial;
4.3. Hyphenation: the hyphens property
The hyphens property determines whether hyphens are allowed to create soft hyphenation capabilities within a line of text.
Hyphenation is controlled word-breaking, in which words are usually not allowed to break to improve the layout of paragraphs. As a rule, word splitting occurs along syllabic or morphemic boundaries and with visual indication of separation (usually by inserting a hyphen, -). In some cases, hyphenation can also change the spelling of a word. In any case, word wrap is only a rendering effect: it should not affect document content, text selection or search.
CSS Text Level 3 does not define precise hyphenation rules, so it is recommended that you choose hyphenation points that are appropriate for your language.
The property is inherited.
hyphens | |
---|---|
Values: | |
none | Words are not hyphenated, even if the characters within the word explicitly define hyphenation. |
manual | Words are hyphenated only in those places where there are characters inside the word that clearly indicate the possibility of word hyphenation (special character -). Default value. |
auto | Words can be split into hyphenation capabilities, as determined automatically by the language-appropriate hyphenation resource, in addition to those explicitly indicated by a hyphenated hyphen. You need to set the language of your content (for example, using the lang HTML attribute or the HTTP Content-Language header) to get correct auto-word wrapping. |
initial | Sets the property value to its default value. |
inherit | Inherits the property value from the parent element. |
Syntax
Hyphens: none; hyphens: manual; hyphens: auto; hyphens: inherit; hyphens: initial;
4.4. Wrap-block overflow: overflow-wrap / word-wrap property
The overflow-wrap property (or its deprecated name word-wrap) specifies whether a non-breaking line can break at unresolved points to prevent a line box from overflowing. Works when the white-space property allows wrapping.
The property is inherited.
overflow-wrap, word-wrap | |
---|---|
Values: | |
normal | Non-breaking lines can only break at permitted break points. Default value. |
break-word | |
anywhere | A contiguous sequence of characters can be broken at an arbitrary point if there are no other acceptable break points in the line. Affects the visual display only, without affecting the original text. No new line is added at the line break point. The soft wrap options provided anywhere are considered when calculating your own minimum content sizes. |
initial | Sets the property value to its default value. |
inherit | Inherits the property value from the parent element. |
Syntax
Overflow-wrap: normal; overflow-wrap: break-word; overflow-wrap: anywhere; overflow-wrap: inherit; overflow-wrap: initial;
5. Align and justify lines
Line alignment and alignment control how inline content is distributed in a line box.
5.1. A shorthand for aligning text: the text-align property
A block of text is a collection of linear blocks. The text-align property sets the text-align-all and text-align-last properties and describes how the line-level boxes in each line box are aligned with the start and end sides of the line box. Values \u200b\u200bother than justify-all or match-parent are assigned to text-align-all and reset to text-align-last to auto.
The property is inherited.
text-align | |
---|---|
Values: | |
start | Line-level content is aligned with the start edge of the line box. Default value. |
end | Line-level content is aligned to the trailing edge of the line box. |
left | Line-level content is aligned to the left of the line box line. In vertical writing systems, this will be the physical top or bottom, depending on the orientation of the text. |
right | Line-level content is right-aligned on the line box of the line box. In vertical writing systems, this will be the physical top or bottom, depending on the orientation of the text. |
center | Line-level content is centered within the line box. |
justify | The text is aligned to the width of the inline box to precisely fill the line box, snuggling to the left and right edges of the parent element. Unless otherwise specified in text-align-last, the last line before a forced break or the end of a block is aligned to the beginning. Spaces between words and letters are distributed so that the length of all lines is equal. Different browsers can increase both the spacing between words and the spacing between letters. |
justify-all | Sets text-align-all and text-align-last to justify, also aligning the last line. |
match-parent | The value behaves the same as inherit except that the inherited start or end value is interpreted relative to the direction value (or the original containing block if there is no parent) and results in the computed value of left or right. |
inherit | Inherits the property value from the parent element. |
Syntax
Text-align: start; text-align: end; text-align: left; text-align: right; text-align: center; text-align: justify; text-align: justify-all; text-align: match-parent; text-align: inherit;
5.2. Default text alignment: text-align-all property
The text-align-all property is a shorthand version of the text-align property that determines the alignment of all lines of content in the block container, except for the last lines, which are overridden by text-align-last. Accepts the values \u200b\u200bstart, end, left, right, center, justify, and match-parent.
The property is inherited.
Syntax
Text-align-all: start; text-align-all: end; text-align-all: left; text-align-all: right; text-align-all: center; text-align-all: justify; text-align-all: match-parent; text-align-all: inherit;
5.3. Align the last line: the text-align-last property
The text-align-last property describes how the last line of a block or line is aligned immediately before a forced line break.
If set to auto, the content on the corresponding line is aligned to text-align-all, unless justify is set for text-align-all, in which case it is aligned to the start of the block. All other values \u200b\u200bare interpreted as described for text-align.
The values \u200b\u200bare auto, start, end, left, right, center, justify, and match-parent.
The property is inherited.
Syntax
Text-align-last: auto; text-align-last: start; text-align-last: end; text-align-last: left; text-align-last: right; text-align-last: center; text-align-last: justify; text-align-last: match-parent;
6. Gaps
CSS allows you to control the spacing between words and typographic characters using the word-spacing and letter-spacing properties.
6.1. Spacing between words: the word-spacing property
The word-spacing property specifies additional spacing between words.
Sets the spacing between words. Positive and negative values \u200b\u200bcan be used. With a negative meaning, words can overlap.
The value of word-spacing is affected by the value of the text-align property when text is justified.
The property is inherited.
Syntax
Word-spacing: normal; word-spacing: 1px; word-spacing: 0.2em; word-spacing: 50%; word-spacing: inherit; word-spacing: initial;
6.2. Tracking: the letter-spacing property
The letter-spacing property specifies the additional spacing, or tracking, between adjacent typographic characters. Letter spacing is complementary to and word-spacing. User agents can further increase or decrease the spacing between typographic character units to align text, depending on the alignment rules in place.
The property is inherited.
Syntax
Letter-spacing: normal; letter-spacing: 0.1em; letter-spacing: 2px; letter-spacing: inherit; letter-spacing: initial;
7. First line indent: text-indent property
The text-indent property specifies the indentation applied to lines of inline content in a block. The padding is treated as a margin applied to the start edge of the line box.
If there is an image in the first line of a block element, then it will move along with the rest of the text.
The property is inherited.
Syntax
Text-indent: 5mm; text-indent: 20px; text-indent: 5%; text-indent: 2em each-line; text-indent: 2em hanging; text-indent: inherit; text-indent: initial;
Sets the alignment of the last line of a block of text.
brief information
Designations
Description | Example | |
---|---|---|
<тип> | Indicates the type of value. | <размер> |
A && B | The values \u200b\u200bmust be displayed in the order shown. | <размер> && <цвет> |
A | B | Indicates that only one of the suggested values \u200b\u200bshould be selected (A or B). | normal | small-caps |
A || B | Each value can be used alone or in conjunction with others in any order. | width || count |
Groups values. | [crop || cross] | |
* | Repeat zero or more times. | [,<время>]* |
+ | Repeat one or more times. | <число>+ |
? | The specified type, word or group is optional. | inset? |
(A, B) | Repeat at least A, but no more than B times. | <радиус>{1,4} |
# | Repeat one or more times, separated by commas. | <время># |
The values
auto Matches the alignment specified by the text-align property, except for the justify value. For it, the alignment will be like start. start The line is aligned to the start edge of the block, which can vary depending on the direction of the text (left to right or right to left). end The line is aligned to the end edge of the block, it is determined by the direction of the text. left The line is left-aligned. right The line is right-aligned. center The line is centered. justify The string is justified. If there is only one word in the last line, then it will be left justified.
The influence of different values \u200b\u200bon the position of the text is shown in table. 1.
Value | Alignment | Type of text |
---|---|---|
left | Left aligned | |
right | Right edge | ![]() |
center | Center | ![]() |
justify | By width | ![]() |
Sandbox
Winnie the Pooh was always not averse to a little refreshment, especially at eleven o'clock in the morning, because at this time breakfast had already ended long ago, and dinner had not even thought to start. And, of course, he was terribly happy to see Rabbit taking out cups and plates.
div (text-align-last: start;)
Example
Object Model
An object.style.textAlignLast
Note
Internet Explorer and Edge do not support start and end values.
Firefox version 49 supports the -moz-text-align-last property.
Specification
Each specification goes through several stages of approval.
- Recommendation - This specification is endorsed by the W3C and recommended as a standard.
- Candidate Recommendation ( Possible recommendation) - the group responsible for the standard is satisfied that it is in line with its objectives, but the help of the developer community is required to implement the standard.
- Proposed Recommendation ( Suggested recommendation) - At this point, the document is submitted to the W3C Advisory Council for final approval.
- Working Draft - A more mature version of the draft after discussion and revision for community review.
- Editor "s draft ( Editorial draft) - a draft version of the standard after editing by the project editors.
- Draft ( Draft specification) is the first draft of the standard.
HTML tags defining text alignment, indentation
Justified text used in typography
The example below shows how to align text to width pages:
align \u003d "left" | align \u003d "right" |
---|---|
The number of workers employed in the service sector and information dissemination is growing every day. If the farm and factory were the symbols of past centuries, then the symbol of the current 21st century is an office equipped with computers that have access to the information flow. |
|
align \u003d "justify" | align \u003d "center" |
The number of workers employed in the service sector and information dissemination is growing every day. If the farm and factory were the symbols of past centuries, then the symbol of the current 21st century is an office equipped with computers that have access to the information flow. |
The number of workers employed in the service sector and information dissemination is growing every day. If the farm and factory were the symbols of past centuries, then the symbol of the current 21st century is an office equipped with computers that have access to the information flow. |
The justify value ensures uniform right and left alignment of text, i.e in width... This method is widely used in print.
Aligning text in HTML center and width
Center align text in HTML, text to the right:
Result:
Attributes and values
- align \u003d "left" - defines align text to the left (default).
- align \u003d "center" - aligns text to the center.
- align \u003d "right" - aligns text to the right.
Alignment | HTML text indent
HTML text and its indentation to the left of the page
We will produce indent text on the left in two ways:
Result:
View in a new window.
Hello dear readers of the blog site. Today we continue to study and we have next in turn the properties text-decoration, vertical-align, text-align, text-indent and a number of others, which help to design the appearance of texts in Html code.
In the last article, we looked at properties that are intended to customize the appearance of fonts when.
Well, and even earlier, we examined all types in detail, learned how they can be grouped and what priorities the browser sets when interpreting them. True, all this was divided into several articles, so in order not to get confused, I advise you to study the materials in the order given in.
Text-decoration, text-align, text-indent in CSS
How to work with text in Css? It is logical to assume that there are specially designed rules for this purpose. Let's start with text-align, which is actually a replacement for the align attribute (it was used to align content like P paragraphs or headings).
It has only four possible meanings:
The meaning remains the same as it was before. Text align Is the horizontal alignment of lines. This rule applies only to block elements (paragraphs, headings, etc.), i.e. those tags in which multiple lines may appear. Because Since there can be only one row inline elements, there is no particular point in using text-align in them.
It is clear that the values \u200b\u200bof this rule mean alignment, respectively: to the left (left), to the right (right), to the center (center) and to the width of the page (Justify - simultaneously to the left and right by increasing the distance between words) ... It goes without saying that the Justify value should be used for elements with at least several lines of text, otherwise there will be no visible effect from this.
For example, I justified the previous paragraph in width (you can see it has even borders on both the left and right) using:
Text-align: justify;
By default, text is horizontally aligned to the left, i.e. you do not need to write text-align: left specifically, unless, of course, you have previously specified a different alignment. By the way, I aligned this paragraph in the center (center) again for an illustrative example, but here, I think, everything is clear.
Next css rule text-indent allows you to set a red line, for example, for text in a paragraph tag P. The indentation of the red line can be set by specifying a value (both with a plus sign and with a minus sign, using) or using percentages:
What are percentages calculated from in text-indent? From the width of the area that is set aside for the text. Those. Css rule text-indent: 50% will set the red line equal to half the length of this same line. Well, this paragraph is just an example of such a rule.
Or you can, for example, set a negative value for the red line in text-indent, and then we will get approximately what you see in this paragraph. To achieve this, I wrote the following CSS rule for the paragraph tag P:
Text-indent: -1em;
Well, a common use of text-indent (to set a standard red line) might look like this: text-indent: 40px; (applied to this paragraph by the way). This rule, like the text-align discussed earlier, only applies to block elements, i.e. where multiple lines may appear (paragraphs, headings, etc.).
So now let's get to text-decoration (design using a horizontal line), which is already applied to all Html elements (both inline and block).
It can have only four meanings:
Those. can be used with text-decoration: overline, line-through or underline, well, or use none at all. Some Html elements already have a horizontal line by default, for example (they are underlined by default).
Therefore, highlighting something else with underlining (except for hyperlinks) is not good, because in the subconscious of users it is written that once it is underlined (and also highlighted in color), it means that you can click on this to go. But by highlighting normal text with underlining, you are misleading the user and subsequent disappointment with your resource (he thought, but it turned out that ...).
The nuance in using the Css text-decoration rule is that you can write three (or two) values \u200b\u200bat once for any Html element (omitting none) and as a result you get overlined-underlined-strikethrough text fragment (sounds cool and looks, doesn't it?):
Text-decoration: underline overline line-through;
Values \u200b\u200bfor text decoration (if you want to use several of them at once) should be written separated by space character.
Vertical-align - vertical alignment
Next we have vertical alignment - vertical-align. For almost all elements in the Html code, it means the alignment of inline elements with text relative to their baseline. True, for this it means a little different - all the content that is in these cells will be aligned vertically.
For Css, the vertical-align rule can use the following values:
Rows are aligned to the baseline by default. Look, I applied to this piece of text increase the font and these two pieces are aligned with the base (bottom) line. And vertical alignment with vertical-align is precisely intended to change the way lines are aligned.
For example, if I write vertical-align: baseline for the same enlarged piece of text, then no changes will happen, since the baseline value is used for this default css rule.
By the way, numbers can be used as values \u200b\u200bfor it, and the inscription vertical-align: 0 will mean the same as vertical-align: baseline, i.e. baseline value is equal to zero. Therefore, if we want to indicate any shift in the vertical alignment, then this shift will be indicated relative to the baseline (or zero).
You can write like this:
Vertical-align: 10px;
And we get shift of the fragment with the enlarged font up 10 pixels from the baseline. If we write a negative value:
Vertical-align: -10px;
Then we get moving the fragment down relative to the baseline. The examples show that due to the shift, the line height has increased so that the text fits in it without running over the adjacent line. The shift can also be set in Em and Ex, well, and as a percentage, which will be counted from the line height of this element (remember in the last article we learned how to set it using).
To vertically align the contents of table cells in vertical-align, you should use the Top and Bottom values \u200b\u200bto get the content aligned to the top and bottom of the cell, respectively (well, middle in the table cell is used as the default vertical alignment value).
And for font elements, you can use text-top, text-bottom, middle. Let's apply for example to this piece of text value:
Vertical-align: middle;
What happened as a result? The middle line of the enlarged fragment is aligned with the baseline of the normal text, i.e. we got a vertical centerline alignment. For text-top and text-bottom everything will be the same. This is text-top, and so is text-bottom.
The Css values \u200b\u200bof the vertical-align sub and super property correspond to the sub- and superscript, which took place in pure Html (before using CSS properties for visual design).
Text-transform, letter-spacing, word-spacing and white-space
None is used by default and means that the characters in the text will not change in any way - as written in Html, they will be displayed. The Uppercase value for text-transform will transform all letters in the fragment to uppercase ( an example is shown in this sentence, where the rule text-transform: uppercase was used, and the letters were originally written in lowercase).
The lowercase value for the Css text-transform rule will allow you to transform all characters in the fragment to lowercase, well, while the capitalize value will make all the first letters of the word uppercase ( example in this sentence - text-transform: capitalize). Those. using text-transform, you can do anything with plain text, and then easily put everything back.
Therefore, if, for example, you have a task to make all headings written only in capital letters, then in Html write them usually, and make them capitalized in CSS using text-transform: uppercase. Then, if you decide to change something back, then it is enough to make only a small change in the styles, and not in the content of all 100,500 headings on your site.
By default, both letter-spacing and word-spacing are set to Normal, or this is the same as zero (i.e. the distance between characters and words does not change in any way). The magnitude of the change in distance in these rules can be indicated only in pixels, either Em or Ex, but not in percent.
However, you can use both positive (sparseness of characters or words) and negative values \u200b\u200b(convergence of characters or words). For example, you can "Like this to sparse the characters in this phrase" using the following Css rule:
Letter-spacing: 0.4em;
Or you can "Like this to bring the characters together in this phrase" through:
Letter-spacing: -1px;
The same can be said about word-spacing with the only difference that the distance will change between words, as, for example, in this phrase, using this CSS construction:
Word-spacing: 4em;
Similarly, negative values \u200b\u200bcan be used in word-spacing to decrease the distance between words.
Well, and the last Css rule for today, which allows you to style text in a certain way in Html code, is white-space... It is responsible for displaying whitespace characters on a web page, which took place when writing Html code.
As you remember from the article about, the browser, when parsing the code, combines all spaces, line breaks and tabs into one single space, and carries out line breaks on the web page exactly by the whitespaces that took place in the code.
So, white space can take one of three values:
It is clear that the default value is Normal and in this case everything is displayed as I described just above. But when using the Pre value, we get a complete analogy with using, i.e. on the web page, the text will be displayed with all those extra whitespace characters that took place when writing the code, and the browser will not be able to make transfers on them.
Well, and the meaning nowrap will simply prevent the browser from wrapping on whitespace it finds inside a white-space: nowrap CSS snippet. You can also try how it all works by creating a simple Html file and enclosing any piece of text in such tags:
Good luck to you! See you soon on the blog site pages
You might be interested
List style (type, image, position) - Css rules for customizing the appearance of lists in Html code
Positioning with Z-index and CSS Cursor rule to change mouse cursor
Padding, Margin and Border - we set internal and external margins in CSS, as well as borders for all sides (top, bottom, left, right)
What is CSS for, how to connect cascading style sheets to an Html document and the basics of the syntax of this language
Float and clear in CSS - block layout tools
CSS - what is it, how cascading style sheets are linked to html code using Style and Link
Dimension Units (Pixels, Em and Ex) and CSS Rules Inheritance
Selectors for tag, class (class), Id and generic, as well as attribute selectors in modern CSS
Position (absolute, relative and fixed) - ways of positioning Html elements in CSS (rules left, right, top and bottom)
Background in CSS (color, position, image, repeat, attachment) - all for setting the background color or background image of Html elements