Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Centering a Placeholder and Input Text in a Text Field

Tags:

html

css

I was wondering if it was possible to center a placeholder and the input which the user will enter in the Text Field. I imagine it would be possible yet I cant figure it out. could anyone help? my code for the Text Field in question is below...

<input type="text" style="font-weight:bold:" name="kword" id="kword" autofocus ="on" placeholder="Enter Keyword(s)" autocomplete ="on"/>

Thanks

like image 418
user1662306 Avatar asked Sep 13 '12 10:09

user1662306


People also ask

How do you center a placeholder text vertically in textarea?

Use the line-height property to make the placeholder vertically centered.

Can you adjust the alignment of text within a placeholder?

You can align the placeholder text (right, left or center) using CSS ::placeholder selector property.

How do I center align text in a field in HTML?

If you only have one or a few blocks of text to center, add the style attribute to the element's opening tag and use the "text-align" property.

What is placeholder in text field?

The placeholder attribute specifies a short hint that describes the expected value of an input field (e.g. a sample value or a short description of the expected format). The short hint is displayed in the input field before the user enters a value.


1 Answers

This can be used to text-align:center

CSS:

input, input[placeholder] {
    text-align: center;
}
like image 78
Rohit Azad Malik Avatar answered Sep 20 '22 02:09

Rohit Azad Malik