including .css files

simpledesign

New Member
Hello all,

I hope this is the right forum for this message. I have a .css file, which has some styling. I would like to include this file as is in a jsp page.

I can include it using the LINK tag, but then, when I save this page the .css file will be saved in a separate directory, which is not required. All the styling should be saved when the page saves.

I can always go and put the contents of the .css file within the STYLE tag, but I wanted to know whether there is another way for me to just include this .css file within the STYLE tag, or just include this .css file, so that its contents would be taken...

@import is not working. A response would be great. I hope I conveyed my situation correctly.

Thanks for looking in

gerard
 

Kiwiberry

New Member
When you link the CSS file in a page it should be relative to the page location. For example, I keep all my CSS stuff in one folder called CSS. My link tag looks like
<link rel="stylesheet" type="text/css" href="CSS/style.css">
from my homepage. I could just as well have the css file in my home directory, but I like it to be a bit more organized. I know BWD is probably the CSS expert, maybe he can elaborate on what you need to do.
 

Kiwiberry

New Member
If you've got the URL, we could take a look at the source code, and maybe see what's going on. Also, add your css file to the post.
 

simpledesign

New Member
.css file code

thanks for the reply.


Can I include a .css file inside a style tag, so that the styles are got from that .css file without having to put all the code from that file.

<style>
@import url(css/general.css);
</style>


Can I do something like this.

If yes, I am unable to get it working.

Kindly let me know

Thanks
 

Kiwiberry

New Member
<style>
@import url(css/general.css);
</style>
I'm not sure what your trying to do with that code, but If you want lets say a paragraph to be formatted a certain way you could do this in the CSS file:

p {
font-family: "times new roman";
font-style: normal;
font-variant: normal;
font-weight: normal;
font-size: 16px;
line-height: normal;
font-size-adjust: none;
font-stretch: normal
}

Then on your web page any paragraph with tags <p> and </p> willl all be formatted like you specified above.

You can also build a class like this:

p.small {
text-align: center;
font-family: "san serif";
font-style: normal;
font-variant: normal;
font-weight: normal;
font-size: 10px;
line-height: normal;
font-size-adjust: none;
font-stretch: normal;
}

The .small is considered a class and in the html it would look like

<p class="small"> and </p>
 

Kiwiberry

New Member
I guess I'm having trouble following what you’re trying to accomplish. My understanding is that the .css files are meant to replace the <style> tags. so if you want everything formatted in the same manner you'd put it in the css file and you use the <style> tag for those instances that may not occur very often or something you wanted to format uniquely.
 

StephanieCordray

New Member
I think he's trying to get the code right for including a stylesheet in a java server page, kiwi. I'm not a big java fan so I'm kinda guessing that's what he is looking for.
 

simpledesign

New Member
.css include

Thanks for your replies.

I am sure you havent understood my problem.


Can I include my .css file using a particular syntax.


Can you give me an example as to how I can do it without using the LINK tag.

because the link tag will make another directory.

I want the styles to be on the same page, not coming from another location.

Let me know whether I have asked the question correctly.

Thanks
 

simpledesign

New Member
.css file in a jsp

Hello,

As you might have guessed right. I am indeed trying to include the .css file in a .jsp.

there is a style tag in it already.

Please help me how to do it.

Thanks
 

StephanieCordray

New Member
You have to link to it to make it an include... the style tag is for defining within the page...

eg. <style font="arial" size="2" </style> A .css file takes over those duties and makes the tag unnecessary.
 
Last edited:

simpledesign

New Member
StephanieCordray said:
You have to link to it to make it an include... the style tag is for defining within the page...

eg. <style font="arial" size="2" </style> A .css file takes over those duties and makes the tag unnecessary.

Thanks for the reply.

Is there any other way other than using the <LINK> tag.

Cause, if I use the link tag, when I download the page, the linked files are saved in a directory that will dowload along with the page.

I hope you are getting my question.

Thanks for your reply
 

simpledesign

New Member
StephanieCordray said:
the css code goes in between in the head tag, not the body of the page... It shouldn't show up in your links directory in that case.

Thanks for the reply.

I have a style tag in the head. All I want is to find out whether I could include a .cc file in the style tag instead of duplicating the code. Without using the <LINKS> tag.

an Example or something would do

Let me know
Thanks
 

StephanieCordray

New Member
You're misunderstanding what <LINK does.

It's not a command to set up a hyperlink on your page... it's what tells your page where to find the .css file... the url part of it is telling the page where the file is located... not make a link that somebody can click on.

You don't use the style tag. You don't need the style tag. The .css is your style. That's why you are using a .css file... so you don't have to use style tags. You replace the style tags in the head with the code to get the .css file.
 

simpledesign

New Member
StephanieCordray said:
You're misunderstanding what <LINK does.

It's not a command to set up a hyperlink on your page... it's what tells your page where to find the .css file... the url part of it is telling the page where the file is located... not make a link that somebody can click on.

You don't use the style tag. You don't need the style tag. The .css is your style. That's why you are using a .css file... so you don't have to use style tags. You replace the style tags in the head with the code to get the .css file.


Thanks for the reply.

Instead of using the contents of the .css , can i just include the .css file, like an import statement in java.

hope i have clarified any doubts you had.

thanks
 

StephanieCordray

New Member
I don't think you can. Even working with jsp there is a lot of HTML coding and for the css to do its work properly it will have to be included in the whole page,between the head tags, not just the javascript. @import is a java command, not an html one.
 

simpledesign

New Member
StephanieCordray said:
I don't think you can. Even working with jsp there is a lot of HTML coding and for the css to do its work properly it will have to be included in the whole page,between the head tags, not just the javascript. @import is a java command, not an html one.


Thanks for the reply.

So I need to put in all the code from the .css file into the <style> </style > tag, am I right?.

so i cannot use @ import or anything else.

let me know
thanks
 

StephanieCordray

New Member
you can't use the <style> </style> tags either. you have to use the <link tag to call up the file. don't think of that tag as putting in a hyperlink. that's not what it's doing. It's calling up the .css file to do it's work is all.
 

Kiwiberry

New Member
Yep Steph, you're right. I completely missed what they were looking for. At least, It looks like you've done some damage to the problem :)
 
Top