Palace Chan
Palace Chan

Reputation: 9223

Why is this button not aligning properly in html?

I have the following html snippet for a submit button:

<input style="height: 30px; width: 120px" type="submit" align="right" name="" value="Submit">

but it is not aligning to the right at all (or middle which is what I want). The align tag doesnt seem to be doing anything why is this the case?

Upvotes: 0

Views: 1043

Answers (2)

Zoltan Toth
Zoltan Toth

Reputation: 47687

The align attribute of HTML has been deprecated ages ago. As a good practice all the styling should be done by CSS and not HTML, like:

<input style="height: 30px; width: 120px; float: right" type="submit" name="" value="Submit">

even a better practice - avoid inline CSS

<style>
input[type=submit] { height: 30px; width: 120px; float: right; }
</style>

<input type="submit" name="" value="Submit" />

Upvotes: 1

Quentin
Quentin

Reputation: 944530

There is no align attribute for the input element. You should use a validator before wondering why markup doesn't work as you expect.

Use CSS for presentation.

You probably want to use either text-align on the parent element or float

Upvotes: 1

Related Questions