Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making <option> text bold

I am trying to make a text bold that is outputted by php.

Tried <b>, <strong> and CSS but it didnt work.

My php:

function generateWeekNumbers() { //Generate a list with week numbers for dropdown
    $weekCount = 53;
    $currentWeek = getWeekNumber();
    for($i=1;$i<$weekCount;$i++)
    {
        if ($i == $currentWeek) {
            echo '<option><span class="week">Week '.$i.'</span></option>';
        } else {
            echo '<option>Week '.$i.'</option>';
        }
    }
}

My css on the actual page:

.week {
   font-weight: bold;
}

Also tried:

echo '<option><b>Week '.$i.'</b></option>';

Hope someone can help.

like image 822
user2911924 Avatar asked Jan 07 '14 11:01

user2911924


People also ask

How do you make bold options in HTML?

To bold the text in HTML, use either the strong tag or the b (bold) tag. Browsers will bold the text inside both of these tags the same, but the strong tag indicates that the text is of particular importance or urgency. You can also bold text with the CSS font-weight property set to “bold.”

What is the code for bold text?

<b> - Bold text.


1 Answers

You can not style option tag by using pure CSS.

You should have a look at this library.

http://ivaynberg.github.io/select2/

like image 191
Merlin Avatar answered Oct 21 '22 11:10

Merlin