How to set the color and font style of placeholder text
Asked Answered
T

6

15

I want to set the color to the placeholder, change the font style to bold, and increase the size.

How can I achieve this? Should I give style to the placeholder, or is there any other way can I achieve this? I want to set the color and change font style to work in all browsers for select size in the below result.

<!doctype html>



<style>html { font-size: 14px; font-family: Arial, Helvetica, sans-serif; }


.k-dropdown-wrap{
  border-width: 5px !important;
  border-color: #D8D3D3 !important;
}

}



</style>

<link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.2.607/styles/kendo.common-material.min.css" />
<link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.2.607/styles/kendo.material.min.css" />
<link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.2.607/styles/kendo.default.mobile.min.css" />

<script src="//kendo.cdn.telerik.com/2016.2.607/js/jquery.min.js"></script>
<script src="//kendo.cdn.telerik.com/2016.2.607/js/kendo.all.min.js"></script>



    <div id="example" role="application">
        <div id="tshirt-view" class="demo-section k-content">

        
        <select id="size" placeholder="Select City..." style="width: 300px;" >
          <option />
          <option />Newyork
          <option />Hyderabad
          <option />Bangalore
          <option />Kolkata
          <option />Delhi
        </select>


    </div>

        <script>
            $(document).ready(function() {
                // create ComboBox from input HTML element

                // create ComboBox from select HTML element
                $("#size").kendoComboBox();


                var select = $("#size").data("kendoComboBox");



            });


        </script>
    </div></!doctype>
Tiresome answered 20/7, 2016 at 17:47 Comment(1)
Possible duplicate of Change an input's HTML5 placeholder color with CSSCargile
T
27

You can use the following code for cross-browser support:

For Google Chrome:

.element::-webkit-input-placeholder {
    color: blue;
    font-weight: bold;
}

For Mozilla Firefox:

.element::-moz-placeholder {
    color: blue;
    font-weight: bold;
}

For Internet Explorer:

.element:-ms-input-placeholder {
    color: blue;
    font-weight: bold;
} 

For Opera:

.element:-o-input-placeholder {
    color: blue;
    font-weight: bold;
} 
Tampere answered 20/7, 2016 at 17:50 Comment(6)
How to add bold? @Angel PolitisTiresome
@Tiresome put font-weight: bold. I'll edit to show you.Tampere
Glad I could help you @TiresomeTampere
can i put all css codes in my code i mean to add the style i mean if i put all codes only it work for all browsers ..?Tiresome
You have to put all of them @Tiresome if you want cross-browser support.Tampere
oh ok wow great sense of all css codes for all browsers good really appreciable @angel politisTiresome
S
8

you can find this and more css tricks here

https://css-tricks.com/snippets/css/style-placeholder-text/

::-webkit-input-placeholder {
   color: red;
   font-weight: 800;
}

:-moz-placeholder { /* Firefox 18- */
   color: red;  
   font-weight: 800;
}

::-moz-placeholder {  /* Firefox 19+ */
   color: red;  
   font-weight: 800;
}

:-ms-input-placeholder {  
   color: red;  
   font-weight: 800;
}
<!doctype html>



<style>html { font-size: 14px; font-family: Arial, Helvetica, sans-serif; }


.k-dropdown-wrap{
  border-width: 5px !important;
  border-color: #D8D3D3 !important;
}
::-webkit-input-placeholder {
   color: red;
}
}



</style>

<link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.2.607/styles/kendo.common-material.min.css" />
<link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.2.607/styles/kendo.material.min.css" />
<link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.2.607/styles/kendo.default.mobile.min.css" />

<script src="//kendo.cdn.telerik.com/2016.2.607/js/jquery.min.js"></script>
<script src="//kendo.cdn.telerik.com/2016.2.607/js/kendo.all.min.js"></script>



    <div id="example" role="application">
        <div id="tshirt-view" class="demo-section k-content">

        <h4 style="margin-bottom: .5em;">Select City</h4>
        <select id="size" placeholder="Select City..." style="width: 300px;" >
          <option />
          <option />Newyork
          <option />Hyderabad
          <option />Bangalore
          <option />Kolkata
          <option />Delhi
        </select>


    </div>

        <script>
            $(document).ready(function() {
                // create ComboBox from input HTML element

                // create ComboBox from select HTML element
                $("#size").kendoComboBox();


                var select = $("#size").data("kendoComboBox");



            });


        </script>
    </div></!doctype>
Sightless answered 20/7, 2016 at 17:53 Comment(0)
S
4

You can use the placeholder pseudo element And font-weight to make it bolder

<!doctype html>



<style>html { font-size: 14px; font-family: Arial, Helvetica, sans-serif; }


.k-dropdown-wrap{
  border-width: 5px !important;
  border-color: #D8D3D3 !important;
}
    ::-webkit-input-placeholder {
        font-weight: 800; 
        font-size: 16px;
    }
    :-moz-placeholder {
        font-weight: 800; 
        font-size: 16px;
    }
    ::-moz-placeholder {
        font-weight: 800; 
        font-size: 16px;
    }
    :-ms-input-placeholder {
        font-weight: 800; 
        font-size: 16px;
    }
}



</style>

<link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.2.607/styles/kendo.common-material.min.css" />
<link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.2.607/styles/kendo.material.min.css" />
<link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.2.607/styles/kendo.default.mobile.min.css" />

<script src="//kendo.cdn.telerik.com/2016.2.607/js/jquery.min.js"></script>
<script src="//kendo.cdn.telerik.com/2016.2.607/js/kendo.all.min.js"></script>



    <div id="example" role="application">
        <div id="tshirt-view" class="demo-section k-content">

        <h4 style="margin-bottom: .5em;">Select City</h4>
        <select id="size" placeholder="Select City..." style="width: 300px;" >
          <option />
          <option />Newyork
          <option />Hyderabad
          <option />Bangalore
          <option />Kolkata
          <option />Delhi
        </select>


    </div>

        <script>
            $(document).ready(function() {
                // create ComboBox from input HTML element

                // create ComboBox from select HTML element
                $("#size").kendoComboBox();


                var select = $("#size").data("kendoComboBox");



            });


        </script>
    </div></!doctype>
Suburb answered 20/7, 2016 at 17:51 Comment(0)
L
3

Here is the for customizing placeholder

::-webkit-input-placeholder { /* WebKit, Blink, Edge */
    color:    #909;
    font-size:12px;
}
:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
   color:    #909;
   font-size:12px;
}
::-moz-placeholder { /* Mozilla Firefox 19+ */
   color:    #909;
   font-size:12px;
}
:-ms-input-placeholder { /* Internet Explorer 10-11 */
   color:    #909;
   font-size:12px;
}
Lott answered 20/7, 2016 at 17:59 Comment(0)
O
2

For me, just the font-weight: normal; worked like

.class {
font-weight: normal;  
}  
Outworn answered 1/3, 2019 at 12:14 Comment(0)
C
0

You can use the following code for all browser

input::placeholder {
    color: blue;
    font-weight: bold;
    text-align: left;
}
Changchun answered 29/9, 2022 at 5:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.