PDF download Download Article
Easy tricks to add blank space anywhere on your webpage
PDF download Download Article

Adding extra space between words and paragraphs in HTML is very different than in apps like Microsoft Word. But don't tear out your hair just yet—we'll show you the easiest ways to control spacing between words and lines of text, as well as how to add extra space to the beginning of each paragraph so they are properly indented on the page. This wikiHow article teaches you different ways you can add spaces to your HTML & CSS code.

Adding Space in HTML: Quick Ways

  • To insert a space anywhere in text, type   .
  • Use the line break tag <br> to add a blank line below or above any HTML element.
  • You can use CSS to indent paragraphs and add margin space to the left, right, top, or bottom of any block element.
Method 1
Method 1 of 5:

Adding Space Between Words and Letters

PDF download Download Article
  1. Open your HTML code in a text editor. You can use any text editor, such as Notepad for Windows, or TextEdit for macOS, to edit your code. If you press the spacebar multiple times to add extra space between words or characters, you won't see those extra spaces on your webpage—HTML automatically converts multiple spaces into a single space. You can fix this by using non-breaking space characters instead of pressing the spacebar.
  2. Add one non-breaking space character for every space you want to add. Unlike pressing the spacebar multiple times in your HTML code, typing &nbsp; more than once creates as many spaces as there are instances of &nbsp; . And you can place them anywhere, including between letters.
    • For example, let's say you want three spaces between the words "What will you learn" and "today?" Instead of pressing the spacebar three times, just type &nbsp;&nbsp;&nbsp; between the two segments. Here's an example:
       <!DOCTYPE html> 
       < 
       html 
       > 
       < 
       head 
       > 
       < 
       title 
       > 
      wikiHow: How-to instructions you can trust. </ 
       title 
       > 
       </ 
       head 
       > 
       < 
       body 
       > 
       < 
       p 
       > 
      What will you learn &nbsp;&nbsp;&nbsp; 
      today? </ 
       p 
       > 
       </ 
       body 
       > 
       </ 
       html 
       > 
      
    • Basically, &nbsp; just translates to "one space" in HTML.
    Advertisement
  3. If you want to insert two spaces, four spaces, or indent the beginning of a line, you don't have to type &nbsp; multiple times: [1]
    • Two spaces: Type &ensp;
    • Four spaces: Type &emsp;
  4. Advertisement
Method 2
Method 2 of 5:

Keeping Spaces in Pasted Text

PDF download Download Article
  1. Another way to add more spaces to your code is to use the HTML <pre> tag. This tag essentially displays the text exactly as you type or paste it, spaces and all. Start by opening your code in a text editor like Notepad for Windows or TextEdit for macOS.
  2. Any text you want to keep preformatted with a particular amount of spaces and/or line breaks will go between these tags: [2]
     <!DOCTYPE html> 
     < 
     html 
     > 
     < 
     head 
     > 
     < 
     title 
     > 
    wikiHow: How-to instructions you can trust. </ 
     title 
     > 
     </ 
     head 
     > 
     < 
     body 
     > 
     < 
     pre 
     > 
     </ 
     pre 
     > 
     </ 
     body 
     > 
     </ 
     html 
     > 
    
  3. <pre>'' tags. In this example, we're creating three spaces between words, as well as a line break. When pre-formatting text, any spaces between words, as well as line breaks you create by pressing "Enter" or "Return," will be displayed on the webpage. [3]
     <!DOCTYPE html> 
     < 
     html 
     > 
     < 
     head 
     > 
     < 
     title 
     > 
    wikiHow: How-to instructions you can trust. </ 
     title 
     > 
     </ 
     head 
     > 
     < 
     body 
     > 
     < 
     pre 
     > 
    What   will   you   
    learn   today? </ 
     pre 
     > 
     </ 
     body 
     > 
     </ 
     html 
     > 
    
  4. 4
    Try the white-space property. Another way to add pre-formatted text is to apply the "pre" tag to an entire container (like a paragraph <p> tag) with the white-space property. You can use this property to preserve spacing between words, letters, and lines within a container. The values that will be most useful are pre , which acts like the <pre> tag, and pre-wrap , which retains word-wrapping (to prevent long lines extending past the container) while also retaining custom spacing between words and letters. [4]
    • For example, to get the same behavior as the <pre> tag in the above example, you could use
       < 
       p 
       style 
       = 
       "white-space: pre;" 
       > 
      What   will   you   
      learn   today? </ 
       p 
       > 
      
    • Or, for a longer passage with custom spacing that should still have traditional word wrapping (like a poem), replace pre with pre-wrap .
  5. Advertisement
Method 3
Method 3 of 5:

Inserting Empty Lines (Line Breaks)

PDF download Download Article
  1. Do you want to add extra space between paragraphs or other elements on the page? Pressing Enter or Return a bunch of times in your code won't do the trick, but adding a line break tag <br> will! Start by opening the HTML code of the page you want to edit.
  2. For example, if you want to insert just one extra blank horizontal line between two paragraphs, you'd just type one <br> once. But if you wanted to add three line breaks, you could type it three times: [5] <br><br><br> .
    • In this example, we're adding two lines of extra space between our sentences:
       <!DOCTYPE html> 
       < 
       html 
       > 
       < 
       head 
       > 
       < 
       title 
       > 
      wikiHow: How-to instructions you can trust. </ 
       title 
       > 
       </ 
       head 
       > 
       < 
       body 
       > 
       < 
       pre 
       > 
      What   will   you  
      learn   today? </ 
       pre 
       > 
       < 
       br 
       >< 
       br 
       > 
       < 
       p 
       > 
      You will learn a lot! </ 
       p 
       > 
       </ 
       body 
       > 
       </ 
       html 
       > 
      
  3. Advertisement
Method 4
Method 4 of 5:

Indenting Paragraphs

PDF download Download Article
  1. Let's say you want to indent the beginning of a paragraph with some space—let's say 10 pixels. The best way to do this would be to use CSS (Cascading Style Sheets). We'll cover two ways to do this—one lets you indent each paragraph manually, and another indents all paragraphs at once. Start by opening up your HTML document in a text editor.
  2. If we want to indent the paragraph in our example, we can do so by adding the text-indent property to its <p> tag. [6] In this example, we'll be indenting our paragraph by 10px:
     <!DOCTYPE html> 
     < 
     html 
     > 
     < 
     head 
     > 
     < 
     title 
     > 
    wikiHow: How-to instructions you can trust. </ 
     title 
     > 
     </ 
     head 
     > 
     < 
     body 
     > 
     < 
     p 
     style 
     = 
     "text-indent:10px" 
     > 
    Welcome to wikiHow, the most trusted how-to site on the internet. wikiHow is where trusted research and expert knowledge come together. </ 
     p 
     > 
     < 
     p 
     > 
    Since 2005, wikiHow has helped billions of people learn how to solve problems large and small. We work with credentialed experts, a team of trained researchers, and a devoted community to create the most reliable, comprehensive and delightful how-to content on the Internet. </ 
     p 
     > 
     </ 
     body 
     > 
     </ 
     html 
     > 
    
    • Since we added the text-indent property to just the first paragraph, that is the only paragraph that will be indented. Read on to learn how to indent all paragraphs on the page the same way instead of just one!
  3. If we want to indent all paragraphs on our page, we can do so by defining the paragraph style in CSS. The style section goes into the head of your HTML code, or on a separate style sheet. Let's add ours to the head, which is between the <head> and </head> tags:
     <!DOCTYPE html> 
     < 
     html 
     > 
     < 
     head 
     > 
     < 
     title 
     > 
    wikiHow: How-to instructions you can trust. </ 
     title 
     > 
     < 
     style 
     > 
     </ 
     style 
     > 
     </ 
     head 
     > 
     < 
     body 
     > 
     < 
     p 
     style 
     = 
     "text-indent:10px" 
     > 
    Welcome to wikiHow, the most trusted how-to site on the internet. wikiHow is where trusted research and expert knowledge come together. </ 
     p 
     > 
     < 
     p 
     > 
    Since 2005, wikiHow has helped billions of people learn how to solve problems large and small. We work with credentialed experts, a team of trained researchers, and a devoted community to create the most reliable, comprehensive and delightful how-to content on the Internet. </ 
     p 
     > 
     </ 
     body 
     > 
     </ 
     html 
     > 
    
  4. 4
    Type the indenting code into the style area. So, we want every paragraph to begin with 10px of space, not just one. This means we'll need to create a style for the paragraph tag (<p>) that automatically adds 10px of space to the beginning of the first word in each paragraph. We'll also want to remove the text-indent property from our original example, as it won't be needed anymore. [7] The property should look like this:
     <!DOCTYPE html> 
     < 
     html 
     > 
     < 
     head 
     > 
     < 
     title 
     > 
    wikiHow: How-to instructions you can trust. </ 
     title 
     > 
     < 
     style 
     > 
     p 
     { 
     text 
     : 
     indent 
     : 
     10 
     px 
     ; 
     } 
     </ 
     style 
     > 
     </ 
     head 
     > 
     < 
     body 
     > 
     < 
     p 
     > 
    Welcome to wikiHow, the most trusted how-to site on the internet. wikiHow is where trusted research and expert knowledge come together. </ 
     p 
     > 
     < 
     p 
     > 
    Since 2005, wikiHow has helped billions of people learn how to solve problems large and small. We work with credentialed experts, a team of trained researchers, and a devoted community to create the most reliable, comprehensive and delightful how-to content on the Internet. </ 
     p 
     > 
     </ 
     body 
     > 
     </ 
     html 
     > 
    
    • You can adjust the number of spaces by typing a different number after "text-indent:".
    • You can use unites other than pixels to define the size of your indent, such as percentage (i.e., "text-indent: 15%;") or measurements (e.g., "text-indent: 3mm;"). [8]
  5. Since we've added specific instructions to indent the <p> tag, every paragraph on the page will be indented 2.5em. This goes for our existing paragraphs, and any new paragraphs we add to the page. [9]
  6. Advertisement
Method 5
Method 5 of 5:

Adding Margins & Space Around Elements

PDF download Download Article
  1. 1
    Use the margin properties to add space around elements. If you want to add space on the left, right, top, or bottom of an element, you can increase the space with the various margin properties. This is helpful for when you want to indent an entire block of text or just add additional space around a container. [10]
    • For example, let's say we want an entire paragraph to be surrounded by some white space. If we want that white space to be 50px, we could use

      to add 50px of white space to the left, right, top, and bottom of the paragraph.

    • Now let's say we are working with a <div> that we want to move an inch from the left side of the page. In this case, we can add space just to the left of the block using
      . You can also use margin-right , margin-top , and margin-bottom to the same effect.
    • The margin property works on block elements, including

      ,

      , and h2 .

Community Q&A

Search
Add New Question
  • Question
    If I define lines of text as individual paragraphs, I get a blank space between lines. How do I get rid of that space?
    Community Answer
    Use a line break instead of the paragraph break.
  • Question
    Can I specify more than one CSS class for any HTML element?
    Community Answer
    Yes, it's very simple too. Inside the class attribute, add all the classes you want the element to have, separated by a space. For example, if you had a tag needing the classes "blueFont" and "underline," the class attribute would be: class="blueFont underline"
  • Question
    How do I space HTML code vertically?
    Community Answer
    The most basic is to simply style it with margin and/or padding. Alternatively, read into absolutely positioning an element, then you can specify exactly where on the page you want in, pixel for pixel.
See more answers
Ask a Question
      Advertisement

      Video

      Tips

      • If your spaces turn into strange symbols on the web browser, it's most likely caused by extra data stored in the word processing format not intended for online display. Avoid this by using a plaintext editor like Notepad or TextEdit.
      • CSS is a much more powerful and predictable way to lay out your page, including the spacing of your text.
      Submit a Tip
      All tip submissions are carefully reviewed before being published
      Name
      Please provide your name and last initial
      Thanks for submitting a tip for review!
      Advertisement

      About This Article

      Article Summary X

      1. Type "&nbsp" to add a single space.
      2. Type "&ensp" to add 2 spaces.
      3. Type "&emsp" to add 4 spaces.
      4. Use the non-breaking space (nbsp) 4 times to insert a tab.
      5. Use "br" to add a line break.

      Did this summary help you?
      Thanks to all authors for creating a page that has been read 6,191,625 times.

      Reader Success Stories

      • Anonymous

        Sep 11, 2018

        "I was looking to add space before and after text in a button. this article made my life easy, because &emsp; is ..." more
        Rated this article:
      Share your story

      Is this article up to date?

      Advertisement