user3014926
user3014926

Reputation: 1099

How do I put tabs in HTML page

I have a web page with the menu bar at the top.

I know to put tab in HTML and it can be done like that:

<p style="text-indent: 5em;">
The first line of this paragraph will be indented about five characters, similar to a tabbed indent.
</p>

But my question would be how to do the similar thing inside the menu bar? Here is my code.

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<html>
<head>
<title></title>

<style>
    div.ex
    {
        width:300px;
        padding:10px;
        border:5px solid gray;
        background: white;
        margin-left:auto;
        margin-right:auto;
        margin-top: 200px;
        position: relative;
    }
    p.x {
        color: white;
        font:25px arial,sans-serif;
        position:relative;
        left:20px;
    }
    .align {
        position: absolute;
        left: 8em;
    }
    body
    {
        background-color: #ebebeb;
        top: 55px;
    }
    #rectangle {
        width: 100%;
        height: 70px;
        background: deepskyblue;
        position: fixed;
        top: 0;
        left: 0;
        bottom: 20;
    }
    input[type=button]
    {
        background-color: lawngreen;
        color: white;
    }
    #text {
        padding-top: 80px;
    }
</Style>
</head>
<body>
<div id="rectangle">
<p class="x">Home Page <a href="personal?id=${id}"><input type="button" name="sign up" value="Sign Up"/></a>
 <a href="hello">Home</a> </p>
</div>
<h1 id="text">Hello world, this is your home page.</h1>
<div class="ex">
<h1>签订</h1>
<hr>
${errorMessage}
<form action="register" method="post">
    <p>
        <label>
            ID:
            <input type="text" name="id" value="${person.id}" class="align"/>
        </label>
    </p>
    <p>
        <label>
            密码:
            <input type="password" name="password" class="align"/>
        </label>
    </p>
    <p>
        <label>
            确认密码:
            <input type="password" name="password" class="align"/>
        </label>
    </p>
    <p>
        <label>
            姓名:
            <input type="text" name="name" value="${person.name}" class="align"/>
        </label>
    </p>
    <p>
        <label>
            地址:
            <input type="text" name="address" value="${person.address}" class="align"/>
        </label>
    </p>
    <p>
        <label>
            电话:
            <input type="text" name="phoneNumber" value="${person.phoneNumber}" class="align"/>
        </label>
    </p>
    <input type="submit" value="注册"/>
</form>
</div>
</body>
</html>

In other words, I'd like to put tabs between "sign up" button and "Home" hyperlink. Both are placed in the blue rectangle.

I appreciate if someone could help me.

Upvotes: 0

Views: 158

Answers (2)

Jukka K. Korpela
Jukka K. Korpela

Reputation: 201538

It seems that by “tab”, you really mean horizontal spacing. In that case, set a suitable horizontal margin on some element, e.g.

<input type="button" name="sign up" value="Sign Up" style="margin-right: 5em"/>
<a href="hello">Home</a> 

(Your code needs fixing. For example, an a element must not contain an input element. But this does not affect the spacing issue.)

Upvotes: 1

Diodeus - James MacFarlane
Diodeus - James MacFarlane

Reputation: 114347

You are using the wrong HTML pattern.

Use an unordered list and move the INPUT outside of the LABEL.

<ul>
  <li>
      <label for="name">Name</label>
      <input id="name" />
    </li>
  <li>
      <label for="address1">Address</label>
      <input id="address1" />
    </li>
  <li>
  ....
</ul>

CSS:

label, input {
  display: inline-block;
}

See: http://alistapart.com/article/prettyaccessibleforms

Upvotes: 0

Related Questions