Shubhankar Shubhankar - 1 year ago 237
CSS Question

How to change the label color of the textfield in Struts 2

I am stuck in changing the font color of

<s:textfield name="name" key=""/>

comes from resource bundle. So in JSP HTML page, it displays
User Name
label and a textfield, but I want to change the font of
User Name

Answer Source

You can do this with CSS attribute selector. Give your <s:textfield> an id and reference this id in CSS like that:

<style type="text/css">
  label[for="nameFieldId"] {
    color: red;

<s:textfield id="nameFieldId" name="name" key=""/>

This will work because xhtml theme generates <label> for <s:textfield> tag with for attribute.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download