Search code examples
htmlcssplaceholder

How to style the value of a placeholder like if I want to give a margin at left of that value, what to write in css?


<html>
<body>
    <div class="user_name floatleft fix">
        <input placeholder="User name" type="text"/>
    </div>
</body>
</html>

I want to give some margin at left of "User name" in input. Please help.


Solution

  • Give padding to the input Demo

    input{
        padding-left: 5px;
    }
    

    If you want to be more specific and not effect all inputs in your HTML. You can do this:

    .user_name > input {
        padding-left: 5px;
    }