How To Insert A Space In Html

Table of contents:

How To Insert A Space In Html
How To Insert A Space In Html

Video: How To Insert A Space In Html

Video: How To Insert A Space In Html
Video: 3 Ways to Add Blank Spaces in HTML 2024, November
Anonim

Inserting a space in the html is necessary for the correct display of the text on the web page in accordance with the effects conceived by the author. Depending on the complexity of the task, you can use both regular non-breaking spaces and control the number of spaces using css properties.

How to insert a space in html
How to insert a space in html

It is necessary

html editor

Instructions

Step 1

If you need to insert one ordinary space between words (obtained by pressing the Space key), you do not need to perform any special actions - any number of consecutive ordinary spaces in the html code will look like one on the web page.

Step 2

To keep the exact number of spaces between words, replace each regular space with " (without quotes) - this is the non-breaking space code in html. For example: "There are two spaces between each word." A non-breaking space is inserted between two words and so that they are not separated when wrapped to another line. For automatic placement of non-breaking spaces in the text, it is convenient to use the well-known tool of Artemy Lebedev - "Typograf" (https://www.artlebedev.ru/tools/typograf/).

Step 3

Another way to insert the intended amount of spaces in html between words: enclose the desired part of the text in tags and. Then the words will be displayed in monospaced font, but all the usual spaces between words will be preserved when displayed on the web page. Please note that the tag has some peculiarities: some other tags are not allowed inside it: and ,,,,.

Step 4

A more complex method to control the handling of whitespace: use the white-space css property with the pre or pre-wrap value (without line wrapping inside the element and with line wrapping, respectively). Specify this property in the description of the page style or a separate html-layout element. When using this method, the font does not change to monospaced, and the number of spaces between words is preserved. Example: How do I insert a space into the html code? Or:.free_spaces {white-space: pre-wrap;} … How do I insert a space into the html code?

Recommended: