Shubhankar Shubhankar - 1 year ago 188
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


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.