One place for hosting & domains

      CSS white-space Property


      While this tutorial has content that we believe is of great benefit to our community, we have not yet tested or
      edited it to ensure you have an error-free learning experience. It’s on our list, and we’re working on it!
      You can help us out by using the “report an issue” button at the bottom of the tutorial.

      white-space is a CSS property that helps control how whitespace and line breaks within an element’s text are treated.

      The white-space property can take these values:

      • normal: The default value. Multiple whitespaces are collapsed into one. The text wraps to the next line when needed.
      • nowrap: Multiple whitespaces are collapsed into one, but the text doesn’t wrap to the next line. We’ve already discussed how to use the nowrap value to prevent line breaks.
      • pre: Same results as using the <pre> where all the whitespaces will be kept as is and the text only wraps when line breaks are in the content.
      • pre-line: Multiple whitespaces are collapsed into one, the text breaks to the next line when needed or with line breaks in the content.
      • pre-wrap: Similar to pre, but the text also wraps when needed.

      white-space: normal

      Medusafish banded killifish convict blenny saury threadsail beluga sturgeon. Indian mul mora cisco masu salmon, roosterfish requiem shark longnose lancetfish bluefish red snapper Sacramento splittail giant danio.

      white-space: nowrap

      Medusafish banded killifish convict blenny saury threadsail beluga sturgeon. Indian mul mora cisco masu salmon, roosterfish requiem shark longnose lancetfish bluefish red snapper Sacramento splittail giant danio.

      white-space: pre

      Here I manually included line breaks and extra spaces. Notice the extra line break at the beginning. That’s because in the markup the text start on the line after the <p> element.

      Medusafish banded killifish convict blenny saury threadsail beluga sturgeon. Indian mul mora cisco masu salmon, roosterfish requiem shark longnose lancetfish bluefish red

      snapper Sacramento splittail giant danio.

      pre-line

      Here the text breaks when needed, but I also manually broke the last few words. I included the same extra whitespaces, but they are now collapsed.

      Medusafish banded killifish convict blenny saury threadsail beluga sturgeon. Indian mul mora cisco masu salmon, roosterfish requiem shark longnose lancetfish bluefish red snapper Sacramento splittail giant danio.

      pre-wrap

      Now the extra whitespaces aren’t collapsed.

      Medusafish banded killifish convict blenny saury threadsail beluga sturgeon. Indian mul mora cisco masu salmon, roosterfish requiem shark longnose lancetfish bluefish red snapper Sacramento splittail giant danio.



      Source link


      Leave a Comment