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

Recommended Answers

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

Jump to Post

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)

Jump to Post

Can you please post the JSP file?

PS: Please use code tags here is small help

Jump to Post

All 9 Replies

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

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

i used ....
<LINK href="style1.css" rel="stylesheet" type="text/css">


in <head> tags but it did't work. Plz help

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)

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;
}

Can you please post the JSP file?

PS: Please use code tags here is small help

<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>

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

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.

you can add the following things inside the <head> 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" >
commented: 2 ears to late, with answer that doesn't help. -2
Be a part of the DaniWeb community

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