Hi All,
I hope my problem 'll get solved by posting my query here.
Actually I have div tag with this style.

<style type="text/css">
          .Box {
         display:none;
         }
         .Box1 {
 display:none;
         }
</style>

If i give the div tags directly in the jsp its working fine,,
like this

<s:select label="Occupation Type" id="Workselect" name="background.workType" headerKey="1"  headerValue="--Please Select--" list="#{'S':'Pursuing Education','W':'Working Professional'}" />
         <div  class="Box">
             <s:textfield label="Organization Name" id="ON" name="background.orgName" />
            </div>
            <div  class="Box1">
             <s:textfield id="IN" label="Institute Name" id="Iname" name="background.instName" />
            </div>

but if i wrap it with the form tag its not working.

<s:form action="Register" method="POST" enctype="multipart/form-data">
            <s:select label="Occupation Type" id="Workselect" name="background.workType" headerKey="1"  headerValue="--Please Select--" list="#{'S':'Pursuing Education','W':'Working Professional'}" />
         <div  class="Box">
             <s:textfield label="Organization Name" id="ON" name="background.orgName" />
            </div>
            <div  class="Box1">
             <s:textfield id="IN" label="Institute Name" id="Iname" name="background.instName" />
            </div>
            </s:form>

I donot know how to apply css for divs inside the form tag.
I want to hide the contents of div tag when placed inside the form.
How can i do that?
Appreciate any help

Thanks

Dani AI

Generated

The Struts UI tags you show are server-side JSP tags, so the browser never sees <s:...> — it sees whatever HTML the taglib produces. First step: open View Source or use the browser inspector and confirm the actual DOM contains the div with the Box/Box1 class. If the class is missing or the element is different, the CSS won't match.

Two likely, verifiable causes in the posted code:

  • There is a duplicate id on one s:textfield (you have two id attributes). Duplicate/invalid attributes can lead to unexpected output from the tag library; fix them first.
  • Struts UI themes can add wrapper markup around fields, so the element you expect to style might be a wrapper rather than the input. That means the selector you wrote may not target the generated element.

Practical debugging checklist:

  • Inspect the generated HTML and the element’s computed styles to see which rule sets display. Use the inspector to find the element by class.
  • If another rule overrides your rule, test with higher specificity or an interim display:none !important to confirm it’s a cascade/specificity problem.
  • If Struts is emitting extra wrappers, either apply the class to the right element (the tag’s documented attribute for CSS) or use theme="simple" to minimize generated markup so your layout is predictable.

Notes on earlier replies: was right to flag that the JSP tag library output matters; ’s statement that the browser sees raw <s: tags is incorrect — those are processed server-side. After checking the generated HTML and fixing the duplicate id, the inspector will reveal whether the issue is CSS specificity, missing class, or Struts-generated markup.

Recommended Answers

All 2 Replies

<style type="text/css">
  .Box { display:none;  }
  .Box1 { display:none; }
</style>
<s:form action="Register" method="POST"  enctype="multipart/form-data">
 <s:select label="Occupation Type" id="Workselect" name="background.workType" headerKey="1"  headerValue="--Please Select--" list="#{'S':'Pursuing Education','W':'Working Professional'}" />
 <s:textfield   class="Box" label="Organization Name" id="ON" name="background.orgName" />
 <s:textfield   class="Box1" id="IN" label="Institute Name" id="Iname" name="background.instName" />
 </s:form>

?? the code supplied is not html, check elsewhere than your inline code for other styles defining
<s:
elements,
try the sample code

If a script is changing the s tags into other tags, the styles will not apply. The styles are applied at the time the page originally renders.

The s tags cause a failure to render anything inside them, because html does not have an s tag. They also throw the browser into quirks mode.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.