HTML in "input/select"

Hi can I add html code in "input/select". For instance text in bold ?



  • @Hermand Pessek. Yes you can by passing the 'style' keyword in the option of elgg_view( ) or elgg_view_field( ). See example below


       '#type' => 'select',

       'name' => 'your select name',

       'options_values' => 'array of options',

       'value' => 'can be empty or default value',

       'style' => 'font-weight:bold'


  • Thanks. But I want only one "options_values" to be in bold.


  • You should be able to do it with CSS alone
    $name           = 'cars';
    $options        = ['id'=>"carSelect_1234"];
    $options_values = [["volvo"=>"Volvo"],
       '#type' => 'select',
       'name' => $name,
       'options_values' => $options_values,
       'value' => 'can be empty or default value',
    <select name="cars" id="carSelect_1234">
      <option value="volvo">Volvo</option>
      <option value="saab">Saab</option>
      <option value="mercedes">Mercedes</option>
      <option value="audi">Audi</option>
  • Correction:

    $options_values = ["volvo"=>"Volvo",
Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking