Loading Please Wait...

Logo Lynxsia IT Solutions

CSS Text Spacing

CSS Text Spacing

CSS provides various properties to give space around text, letters, words, line, etc.

  • text-indent
  • letter-spacing
  • line-height
  • word-spacing
  • white-space
Text Indent

The CSS text-indent property sets the length of empty space (indentation) that is put before lines of text in a block

Text Indent Values

each-line: Indentation affects the first line of the block container as well as each line after a forced line break, but does not affect lines after a soft wrap break.

hanging: Inverts which lines are indented. All lines except the first line will be indented.

Length: 5px, 1rem, etc.

Percentage: 5%, 50%, etc.

Global values: inherit, initial, revert, revert-layer, unset.

					 
        
          /* length values */
          text-indent: 3mm;
          text-indent: 40px;

          /* percentage value relative to 
             the containing block width */
          text-indent: 15%;

          /* Keyword values */
          text-indent: 5em each-line;
          text-indent: 5em hanging;
          text-indent: 5em hanging each-line;

          /* Global values */
          text-indent: inherit;
          text-indent: initial;
          text-indent: revert;
          text-indent: revert-layer;
          text-indent: unset;
        
      
Letter Spacing

The CSS letter-spacing property sets the horizontal spacing behavior between text characters.

Letter Spacing Values

Keyword value: normal

Length: 5px, 1rem, etc.

Global values: inherit, initial, revert, revert-layer, unset.

					 
        
          /* Keyword value */
          letter-spacing: normal;

          /* length values */
          letter-spacing: 0.3em;
          letter-spacing: 3px;
          letter-spacing: 0.3px;

          /* Global values */
          letter-spacing: inherit;
          letter-spacing: initial;
          letter-spacing: revert;
          letter-spacing: revert-layer;
          letter-spacing: unset;
        
      
Line Height

The CSS line-height property sets the height of a line box. It's commonly used to set the distance between lines of text.

Line Height Values

Keyword value: normal

Number: 5, 6, 10, etc. (unitless number multiplied by the element own font size)

Length: 5px, 1rem, etc.

Percentage: 5%, 50%, etc.

Global values: inherit, initial, revert, revert-layer, unset.

					 
        
          /* Keyword value */
          line-height: normal;

          /* number values */
          line-height: 3.5;

          /* length values */
          line-height: 3em;

          /* percentage values */
          line-height: 34%;

          /* Global values */
          line-height: inherit;
          line-height: initial;
          line-height: revert;
          line-height: revert-layer;
          line-height: unset;
        
      
Word Spacing

The CSS word-spacing property sets the length of space between words and between tags.

Word Spacing Values

Keyword value: normal

Length: 5px, 1rem, etc.

Global values: inherit, initial, revert, revert-layer, unset.

					 
        
          /* Keyword value */
          word-spacing: normal;

          /* length values */
          word-spacing: 3px;
          word-spacing: 0.3em;

          /* Global values */
          word-spacing: inherit;
          word-spacing: initial;
          word-spacing: revert;
          word-spacing: revert-layer;
          word-spacing: unset;
        
      
White Space

The CSS white-space property sets how white space inside an element is handled.

White Space Values

normal: Sequences of white space are collapsed. Newline characters in the source are handled the same as other white space. Lines are broken as necessary to fill line boxes

nowrap: Collapses white space as for normal, but suppresses line breaks (text wrapping) within the source.

pre: Sequences of white space are preserved. Lines are only broken at newline characters in the source and at <br> elements.

pre-wrap: Sequences of white space are preserved. Lines are broken at newline characters, at <br>, and as necessary to fill line boxes.

pre-line: Sequences of white space are collapsed. Lines are broken at newline characters, at <br>, and as necessary to fill line boxes.

break-spaces:

Global values: inherit, initial, revert, revert-layer, unset.

					 
        
          /* Keyword values */
          white-space: normal;
          white-space: nowrap;
          white-space: pre;
          white-space: pre-wrap;
          white-space: pre-line;
          white-space: break-spaces;

          /* Global values */
          white-space: inherit;
          white-space: initial;
          white-space: revert;
          white-space: revert-layer;
          white-space: unset;
        
      

How you feel about this blog:

Share this blog on:

Report Us

If you find any error in the turtorials, or want to share your suggestion/feedback, feel free to send us email at: info@lynxsia.com

Contact Us
Ads
Logo
Lynxsia IT Solutions

We are concern with various development process like website design & development, E-commerce development, Software development, Application development, SMS & Bulk SMS Provider, PWA Development, and many more..

Kotwali Road, Chhiptehri, Banda, 210001, UP, India

Copyright © 2022, Lynxsia IT Solutions, All rights reserved