user6460587
user6460587

Reputation:

html add space before tag

I am trying to add space before an input tag, and I noticed that Chrome didn't render the whitespace. What can I do to add a space. My code is very straightforward:

    Q: <input type="text" id="q">

notice the space between Q: and the tag. I will use JS if I absolutely have to, but pure HTML is much better.

Upvotes: 1

Views: 4078

Answers (4)

claudios
claudios

Reputation: 6656

Here is the two example of having a whitespace before your input tag. It's either using &nbsp or css. Using css is more neat for me in which you can easily change it's styles. Example below css with one character space.

#q1 {
  margin-left: .5em;
}
<label for="q">Q:</label>&nbsp; <!-- using a space -->
<input type="text" name="q" id="q">

<br />

<label for="q1">Q:</label><!-- using css -->
<input type="text" name="q1" id="q1">

Upvotes: 0

user2384183
user2384183

Reputation:

You could try &nbsp;.

Q:&nbsp;<input type="text" id="q">

Upvotes: 2

frnt
frnt

Reputation: 8795

Add margin-left into you #q,

#q{
  margin-left:10px;
}

Upvotes: 0

Kode.Error404
Kode.Error404

Reputation: 573

If you would like a regular line whitespacing you can use <br> but if you mean the literal whitespace before the the input box, you can use a margin tag to give it more space.

E.g.

 #q{
        margin-left:10px;
    }

Upvotes: 0

Related Questions