Jump to content

[SOLVED] Formatting <option> tags


KevinM1

Recommended Posts

Is it possible to format <option> tags with CSS?  I'd like to have a part of the text within each of my option elements bold.  Trying a <span> in a PHP echo statement hasn't worked.

 

Along the same lines, is there any way for me to include tabs in an option element to help facilitate even spacing of the text within them?  Using \t in a PHP echo statement didn't work.

 

Thanks! :)

Link to comment
Share on other sites

you should be able to use a class and just apply that class to the option element

 

<style>
.blah {
  font-weight: bold;
}
</style>

<select name="name">
  <option class="blah" value="value">hahahaha</option>
  <option value="value">hahahaha</option>
  <option class="blah" value="value">hahahaha</option>
</select>

Link to comment
Share on other sites

you should be able to use a class and just apply that class to the option element

 

<style>
.blah {
  font-weight: bold;
}
</style>

<select name="name">
  <option class="blah" value="value">hahahaha</option>
  <option value="value">hahahaha</option>
  <option class="blah" value="value">hahahaha</option>
</select>

 

The above creates something like the following, correct?

 

hahahaha

hahahaha

hahahaha

 

That's not what I'm looking for.  Instead, I want something like:

 

Event Name: Some event

Event Name: Another event

Event Name: Third event

Link to comment
Share on other sites

I looked in a couple of places and the best answer that I can give is:

You can't have other tags inside an option tag. Therefore, you can only apply style to the entire element and not just a certain part.

 

Another observation:

Why do you want to put the words "Event Name" on every single option? That seems a little redundant. Just bring the text out and put it before the drop down box.

Link to comment
Share on other sites

I looked in a couple of places and the best answer that I can give is:

You can't have other tags inside an option tag. Therefore, you can only apply style to the entire element and not just a certain part.

 

Another observation:

Why do you want to put the words "Event Name" on every single option? That seems a little redundant. Just bring the text out and put it before the drop down box.

 

True, putting 'Event Name' in each option is redundant.  For my project, I was planning to highlight user names which are taken from the database as each option is created.  Guess that's not possible.  Thanks for answering. :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.