including .css files

Discussion in 'Web Design' started by simpledesign, Nov 11, 2005.

to remove all ads.
  1. simpledesign

    simpledesign New Member

    Messages:
    8
    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
     
  2. Kiwiberry

    Kiwiberry New Member

    Messages:
    123
    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.
     
  3. Kiwiberry

    Kiwiberry New Member

    Messages:
    123
    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.
     
  4. simpledesign

    simpledesign New Member

    Messages:
    8
    .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
     
  5. StephanieCordray

    StephanieCordray New Member

    Messages:
    1,017
    <LINK rel="stylesheet" type="text/css" href="/jsp/css/general.css">

    Is this close to what you are looking for?
     
  6. Kiwiberry

    Kiwiberry New Member

    Messages:
    123
    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>
     
  7. Kiwiberry

    Kiwiberry New Member

    Messages:
    123
    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.
     
  8. StephanieCordray

    StephanieCordray New Member

    Messages:
    1,017
    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.
     
  9. simpledesign

    simpledesign New Member

    Messages:
    8
    .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
     
  10. simpledesign

    simpledesign New Member

    Messages:
    8
    .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
     
  11. StephanieCordray

    StephanieCordray New Member

    Messages:
    1,017
    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: Nov 12, 2005
  12. simpledesign

    simpledesign New Member

    Messages:
    8
    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
     
  13. StephanieCordray

    StephanieCordray New Member

    Messages:
    1,017
    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.
     
  14. simpledesign

    simpledesign New Member

    Messages:
    8
    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
     
  15. StephanieCordray

    StephanieCordray New Member

    Messages:
    1,017
    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.
     
  16. simpledesign

    simpledesign New Member

    Messages:
    8

    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
     
  17. StephanieCordray

    StephanieCordray New Member

    Messages:
    1,017
    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.
     
  18. simpledesign

    simpledesign New Member

    Messages:
    8

    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
     
  19. StephanieCordray

    StephanieCordray New Member

    Messages:
    1,017
    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.
     
  20. Kiwiberry

    Kiwiberry New Member

    Messages:
    123
    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 :)
     

Share This Page