I have a select box and I need to have some of the options' text aligned to the left with the rest to the right, like this:
| option 1 0.5 |
| option 2 1.5 |
Is that possible? I thought about putting div's in the option, but in searching to see if that's allowed I ran across several places that said it wasn't.
Thanks for your help.
Align the text left or right Select the text that you want to align. On the Home tab, in the Paragraph group, click Align Left or Align Right .
On the Home tab, click the Paragraph group's dialog launcher and then click Tabs in the bottom-left corner. Enter 6.5 in the Tab stop position. Click Right in the Alignment section (Figure C). Click Set.
Align a Paragraph To align left, press Ctrl + L. To align right, press Ctrl + R. To align center, press Ctrl + C. To justify, Ctrl + J.
Select the cells that have the text you want aligned. To horizontally align text, pick Align Text Left , Center , or Align Text Right .
The option
element content is taken as plain text (no tags are recognized), so there is no direct way to do it. As a clumsy workaround, you can hand-format the options using a monospace font and use no-break spaces:
<style>
select, option { font-family: Consolas, monospace; }
</style>
<select>
<option>option 1 0.5
<option>option 2 1.5
<option>one more option 110.5
</select>
(where the spaces inside the option
elements are no-break spaces; use
for them if you don’t know how to type no-break spaces in your authoring environment).
A completely different workaround, or approach, is the replace the select
element by a set of checkboxes (or, depending on desired logic, radio buttons) and associated labels. You can then represent this data in a table and set suitable formatting on it:
<table>
<tr><td><input type=checkbox> <td>option 1 <td align=right>0.5
<tr><td><input type=checkbox> <td>option 2<td align=right>1.5
<tr><td><input type=checkbox> <td>one more option <td align=right>110.5
</table>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With