Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Jun 2012
    Posts
    17
    Thanks
    2
    Thanked 0 Times in 0 Posts

    How to make spaces?

    Hello I have created a small text field container thing. I would like to type one piece of text then make a long space in between the first and last word. In order to do this would I have to use multiple text containers? Because I can't make more than one space after the first written word.

    I'm sure you get what I mean, I'm using dreamweaver btw.

  • #2
    New Coder
    Join Date
    Nov 2010
    Location
    Virginia,USA
    Posts
    36
    Thanks
    1
    Thanked 7 Times in 7 Posts
    Have you tried using non breaking spaces? For instance try this

    Code:
    <p>This is my sentence with a big &nbsp;&nbsp;&nbsp; space in it.</p>
    use as many &nbsp; you may need.

  • #3
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,632
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Alternatively

    Code:
    <p>This is my sentence with a big <span style="white-space:pre">      </span> space in it.</p>
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • Users who have thanked felgall for this post:

    badwolf (06-09-2012)

  • #4
    New Coder
    Join Date
    Nov 2010
    Location
    Virginia,USA
    Posts
    36
    Thanks
    1
    Thanked 7 Times in 7 Posts
    Quote Originally Posted by felgall View Post
    Alternatively

    Code:
    <p>This is my sentence with a big <span style="white-space:pre">      </span> space in it.</p>
    Wow thanks felgall! I guess a person really does learn something new everyday. I had no idea there was a definition for white spaces in CSS.

    @Mumrik, Actually I would use the span tag that felgall has recommended. That is the more correct way to do this. Although the &nbsp; will give little bumps at a time. Either way is legal.

  • #5
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,632
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Both ways have their uses. When you know both you can use the more appropriate one in each situation.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #6
    Regular Coder
    Join Date
    Jun 2012
    Location
    Near Chicago, USA
    Posts
    123
    Thanks
    7
    Thanked 19 Times in 19 Posts
    And still one more way

    Code:
    A wide <span style="padding-left:150px;">space</span> within.
    Will

  • #7
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,632
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Quote Originally Posted by Will Bontrager View Post
    And still one more way

    Code:
    A wide <span style="padding-left:150px;">space</span> within.
    Will
    That way is actually adding padding rather than spaces and so you can't specify the number of spaces that is supposed to be there using that method. It is therefore not usable for adding a specific number of spaces between elements in the page the way the other two methods do.

    You might insert whitespace into the text that way by specifying the size in em so that the spacing remains proportional to the text but there'd never be any use for using px there (you should only ever use px for border widths).

    <span style="padding-left:5em;"> and &emsp;&emsp;&emsp;&emsp;&emsp; would be equivalent provided that it and the following word are within the one line - they would behave differently if the browser decided to start a new line in between or after the spaces (using the padding option is the way to keep those spaces together with the following text). The browser can start a new line between &emsp; whereas it can't between &nbsp;
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #8
    Regular Coder
    Join Date
    Jun 2012
    Location
    Near Chicago, USA
    Posts
    123
    Thanks
    7
    Thanked 19 Times in 19 Posts
    You're correct about the spaces, of course, Stephen.

    I had noticed the OP asked for "a long space."

    Will


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •