File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes CSS with Struts-html tags. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "CSS with Struts-html tags." Watch "CSS with Struts-html tags." New topic

CSS with Struts-html tags.

prakash chauhan
Ranch Hand

Joined: Jun 22, 2007
Posts: 81
Hi All,
I want to apply styles to my struts-html tags
for eg:
in jsp:
<html:link action="home">HOME</html:link>

and in my css i want to use something like this:
background-color: #ABC;

can we do it? it does not seem to be working , anything wrong with the code?
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63858

CSS is a client-side technology, Struts is a server-side technology. Your CSS knows nothing about your Struts tags. These tags get translated into HTML which is sent to the browser. It is that HTML that your CSS must match.

[Asking smart questions] [About Bear] [Books by Bear]
prakash chauhan
Ranch Hand

Joined: Jun 22, 2007
Posts: 81
So does that mean that i can't use my struts-html tags with CSS?
any work arounds?
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

Moving to our Struts forum.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Chris Baron
Ranch Hand

Joined: Mar 21, 2003
Posts: 1061
Check the documentation for usage of the attributes "style", "styleClass" and "styleId".

and have a look how it will rendered in the browser's HTML-Source.
Hth cb
Amit Sharma

Joined: Oct 29, 2007
Posts: 4

Have a CSS defined for Anchor tag and you should get that css applied to HTML:link
Struts tag.

I have not tried the above but it should work since when the page gets rendered the Html:link tag get converted to Anchor tag.

prakash chauhan
Ranch Hand

Joined: Jun 22, 2007
Posts: 81
Thanks , i will try this and lets hope it works.
Thanks again.
I agree. Here's the link:
subject: CSS with Struts-html tags.
jQuery in Action, 3rd edition