We have the below dropdown and it populates manually from the user Input.
now if the user is giving multiple spaces in between the words,i can see the spaces are getting ommited.
`
I tried the below CSS also but still not working
<html:select styleId="Id" property="Id" size="1"
styleClass="preserve-space" value="${Form.Id}">
<html:option value="">Select a value </html:option>
<html:options collection="resultlist" property="id" labelProperty="name"/>
</html:select>
<style>
.preserve-space { white-space: pre; font-family: monospace; /* Helps maintain consistent spacing */ } /* For better browser compatibility */
.preserve-space option { white-space: pre; -moz-white-space: pre; /* Firefox */ -webkit-white-space: pre; /* Chrome/Safari */ }
</style>
2
Answers
HTML collapses multiple spaces by default, maybe you can replace them with a special space character as
You can also use the
white-space: pre:
style.It works to preserve spaces in text content.This should solve the limitations of applying CSS styles to
option
tag inside aselect
.Use
instead of spaces: