Is it possible for the options of an HTML select element to include HTML tags?
For example, given the following code:
<select> <option value="one"><b>one is bold</b></option> <option value="two">two has some <span style='color:red;'>red</span> text</option> <option value="three">three is just normal</option> </select>
I would like the options to actually render in HTML. In this application I can play with HTML, CSS, JavaScript (including jQuery). And the HTML itself is being rendered via Django (django.form.fields.select).
Simple selectors (select elements based on name, id, class) Combinator selectors (select elements based on a specific relationship between them) Pseudo-class selectors (select elements based on a certain state)
The <select> Tag.
The key here for me is to build a data array with content for both templateSelection and templateResult . The latter renders fine in the dropdown but any multiline content will not be contained in the select2 element so needs to be displayed inline (or at least on a single line).
Definition and UsageThe <select> element is used to create a drop-down list. The <select> element is most often used in a form, to collect user input. The name attribute is needed to reference the form data after the form is submitted (if you omit the name attribute, no data from the drop-down list will be submitted).
No, you can't do this. <option>
tags cannot contain any other tags.
No, but this: Styling HTML Select may help you and there a lof of detail and votes here:
How to style a <select> dropdown with CSS only without JavaScript?
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