Horje
What is white-space Property in CSS ?

The white-space property in CSS is used to control how white space within an element is handled. It allows you to define whether spaces, tabs, and line breaks should be collapsed or preserved, influencing the layout and presentation of text.

Note: The white-space property can take values like normal, nowrap, and pre.

Syntax:

/* Collapsing consecutive white spaces and wrapping text as needed */
p {
white-space: normal;
}

Features:

  • white-space Property:
    • normal: Collapses consecutive white spaces and wraps text as needed.
    • nowrap: Prevents text from wrapping to the next line.
    • pre: Preserves both spaces and line breaks, displaying text exactly as it appears in the code.
  • Line Breaking: The white-space property also affects how the browser handles line breaks, especially in scenarios like long URLs or code snippets.
  • pre-line and pre-wrap: These values offer variations of preserving white space and line breaks, providing more flexibility.



Reffered: https://www.geeksforgeeks.org


CSS

Related
What is the purpose of the scroll-snap-type Property in CSS ? What is the purpose of the scroll-snap-type Property in CSS ?
How to implement the border-collapse Property in CSS ? How to implement the border-collapse Property in CSS ?
What is the purpose of the will-change Property ? What is the purpose of the will-change Property ?
Explain the use of the hyphens Property in CSS Explain the use of the hyphens Property in CSS
What is the use of the user-select Property? What is the use of the user-select Property?

Type:
Geek
Category:
Coding
Sub Category:
Tutorial
Uploaded by:
Admin
Views:
13