Long Select Field with <optgroup>

I have a long select list with options that can be grouped by some categories. I would like to show each group of options under unsealeactable option group. I know I should at the html tag but do not know where to do that. By the way, I created a custom field that inherits from Select.
I would appreciate any help.