Is it possible to nest a span element inside a form_for label tag? I am trying to achieve this in order to style a specific part of the label using CSS, such as making the text red. While it seems like valid HTML based on my research, it is causing some issues with Rails even though it aligns with my design vision.
The desired HTML output should be:
<label for="zip">ZIP Code -<span class="required">Required</span></label>
However, my current code results in:
<%= form.label :zip, 'ZIP Code -<span class="required">Required</span>' %>
The problem lies in Rails somehow escaping the inner span tag, causing it to display as plain text on the page instead of interpreting it as HTML. The displayed content looks like this:
ZIP Code -<span class="required">Required</span>