954,574 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Adding css to JSP

Please let me know how to add css to a jsp page?

jeetudaljit
Newbie Poster
16 posts since Jul 2008
Reputation Points: 10
Solved Threads: 0
 

Exactly as to any other HTML based document, either use internal or external approach.

peter_budo
Code tags enforcer
Moderator
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
 
Exactly as to any other HTML based document, either use internal or external approach.


i used ....


in tags but it did't work. Plz help

jeetudaljit
Newbie Poster
16 posts since Jul 2008
Reputation Points: 10
Solved Threads: 0
 

Incorrect order of tag elements, it should be as

<head>
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>

also make sure their are in correct directory (in your case together with JSP document)

peter_budo
Code tags enforcer
Moderator
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
 

yes, I have rechecked. . Both files are in same directory.

here is css file

root { 
    display: block;
    font-size: 14px;
  font-style: italic;
  font-weight: normal;
  font-variant: normal;
  color: navy;
  background-color: #ccffcc;
  background-attachment: none;
  font-family: Georgia,'Times New Roman',times,serif;
}
jeetudaljit
Newbie Poster
16 posts since Jul 2008
Reputation Points: 10
Solved Threads: 0
 

Can you please post the JSP file?

PS: Please use code tags here is small help

peter_budo
Code tags enforcer
Moderator
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
 
<html>
    <head>
          
          <LINK href="style1.css" rel="stylesheet" type="text/css">
       
        <title>JSP Page</title>
    </head>
    <body>
        
        <form>
         <h2>Hello World!</h2>
    </form>

    </body>
</html>
jeetudaljit
Newbie Poster
16 posts since Jul 2008
Reputation Points: 10
Solved Threads: 0
 

Just did little bit of search on internet and seems to me there is more trouble with use of the root then you want to go through. Just replace it with html or html,body

peter_budo
Code tags enforcer
Moderator
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
 

Hi Peter.. This problem is solved as I made following changes in jsp
..

<form>
            <root>
            Welcome... To this style1.       
 </root></form>

Thanks a lot for ur help.

jeetudaljit
Newbie Poster
16 posts since Jul 2008
Reputation Points: 10
Solved Threads: 0
 

you can add the following things inside the tag

<meta http-equiv="Content-Style-Type" content="text/css">
<title> Home </title>
<html:base/>
<link HREF="../theme/screens.css" REL="stylesheet" TYPE="text/css" >
shahpraneel
Newbie Poster
1 post since Apr 2010
Reputation Points: 8
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You