Hello I am making a list of elements in a <select>
and I want to divide the options.
For this I want different 'categories' to be displayed as a title (which could not be selected). The problem is that I already tried the conventional line breaks in HTML and it hasn't worked for me. Do you have any idea how to do it?
My idea is that the list looks like this when displayed:
Categoría 1 <-- Este elemento no se puede seleccionar Elemento seleccionable Elemento seleccionable Elemento seleccionable Elemento seleccionable Categoría 2 <-- Este elemento no se puede seleccionar Elemento seleccionable Elemento seleccionable Elemento seleccionable Elemento seleccionable Categoría 3 <-- Este elemento no se puede seleccionar Elemento seleccionable Elemento seleccionable Elemento seleccionable Elemento seleccionable
As a reference I put this site where they do something similar: Convert World .
I am not asking you to design the list for me, I just want to know how to apply the line break and the elements that cannot be selected.
To include "line breaks" you just have to put in the
select
elementoption
without text.To prevent some elements from being selectable, use the attribute
disabled
on theoption
.Another option is to use
optgroup
: