How to insert spaces in HTML

Author: Joan Hall
Date Of Creation: 28 July 2021
Update Date: 23 June 2024
Anonim
how to insert spaces in html
Video: how to insert spaces in html

Content

1 Open an HTML document. This can be done in a regular text editor such as Notepad or TextEdit on Windows. You can also use an HTML file editor such as Adobe Dreamweaver. To open an HTML document:
  • Navigate to the HTML document in Explorer (Windows) or Finder (macOS).
  • Right click on the desired HTML document.
  • Hover over Open With.
  • Select the program in which you want to edit the document.
  • 2 Click on spaceto add a regular space. Place the cursor where you want to insert a space, and then press the "Space" key. In HTML, only one space will appear between words, even if you hit the space multiple times.
  • 3 Enter to add an extra space. It's called a non-breaking space because it doesn't allow you to go to a new line.
    • For example, if you enter Hi everyone, between the words "Hello" and "everyone!" an extra space will be inserted.
    • Keep in mind that too many non-breaking spaces will prevent the browser from making line breaks in the right places, making the text difficult to read.
    • You can also enter  to insert a space.
  • 4 Insert spaces of different lengths. If you want to insert a longer space, use one of the following options:
    • Two spaces - enter
    • Four spaces - enter
    • Indent (Tab Spacing) - enter
  • Method 2 of 3: CSS

    1. 1 Open an HTML or CSS document. The CSS code can be inserted into the head of an HTML document or saved as an external CSS file.
      • The head of the HTML document is located at the top of the file, between the "head>" and "/ head>" tags.
    2. 2 Create a styling section for CSS. The style section is located at the beginning of the HTML code or in a separate style sheet.Use the following tags to create a style section in an HTML document or style sheet.
      • Enter style>to open the style section. All CSS code will go after this tag.
      • Enter / style>to close the style section. All CSS must be placed before this end tag.
    3. 3 Enter the following tag in the style section:p {indent-text: 5em;} This tells the browser to indent it by 5 spaces (in the correct HTML).
      • To set the number of spaces, change the number after "indent-text:".
      • The "em" element matches one space with the specified font size. Other units can be used, such as percent ("Indent-text: 15%;") or millimeters ("Indent-text: 3mm;").
    4. 4 Enter p> where you want to add indentation. Do this inside the HTML document where you want to indent. The text will be indented according to the CSS specifications.

    Method 3 of 3: Preformatted text

    1. 1 Open an HTML document. This can be done in a regular text editor such as Notepad or TextEdit on Windows. You can also use an HTML file editor such as Adobe Dreamweaver. To open an HTML document:
      • Navigate to the HTML document in Explorer (Windows) or Finder (macOS).
      • Right click on the desired HTML document.
      • Hover over Open With.
      • Select the program in which you want to edit the document.
    2. 2 Enter pre> before the text you want to preformat. This is the opening tag for preformatted text.
    3. 3 Enter the text as intended after the "pre>" tag. When preformatting the text, any spaces and line breaks created by pressing Enter will be displayed on the HTML page.
    4. 4 Enter / pre> at the end of the text. This is the closing tag for preformatted text.

    Tips

    • If the browser displays spaces as incomprehensible characters, this is most likely due to additional data; they are stored in word processing format and are not displayed on the screen. To avoid this, work in a regular text editor such as Notepad or TextEdit.
    • CSS is a much more powerful and predictable way of creating the layout of a web page, including word spacing.
    • A non-breaking space is an example of a character entity; it is a code that refers to a character that cannot be entered from the keyboard.

    Warnings

    • HTML symbol for Tab ↹ (tabs) doesn't work the way many people think. There are no tab stops in a regular HTML file, so entering this character will do nothing.
    • Enter HTML in a code editor or plain text file rather than a powerful text editor.