Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS CSS Background Query

  • This topic is empty.
Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #31544
    tjgriffiths1
    Participant

    Hey y’all,

    I am brand new to this, and have been writing in HTML & CSS for a few days now.

    I am trying to upload a background image using an external style sheet, but having no success.

    I know the CSS works as i have tested it with other attributes.

    is there something i’m missing? Here is the code; (VERY SIMPLE)

    HTML FILE: (saved as index.html)

    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



    CSS FILE: (saved as stylesheet.css)

    body
    {
    background-image: url

    (‘http://www.silverlight.net/content/samples/sl2/silverlightairlines/run/Images/Background.jp

    g’)
    }

    Like i say, i’ve taken it back to the simplest form to rule out other factors.

    Any advice would be gratefully recieved!

    #62332
    Sirlon
    Member

    Hi
    You do not need the -image or ‘ in there but a ; at the end of the line ;) And these linebreaks are only because you copy pasted it in here right ? ^^

    body{ background: url(http://www.silverlight.net/content/samples/sl2/silverlightairlines/run/Images/Background.jpg); }

    #62314
    SAiNT
    Participant

    you should wrap your code inside the CODE tag when posting at forums…

    #62315
    tjgriffiths1
    Participant

    Hi Sirlon,

    Thanks for the reply, still no luck. could it be the browser?

    and yeh, you’re right, the line breaks were a direct copy paste!

    #62317
    tjgriffiths1
    Participant

    thanks saint, i just found that out! Still learning all this stuff.

    #62318
    tjgriffiths1
    Participant

    ok guys, i’ve tried it out in various browsers now and still no luck.

    does the background image need to be a certain file type?

    #62320
    Sirlon
    Member

    Hmm, i have tested it and it is working.

    and
    No, it can be any image file. (eg. jpg, gif or png)

    #62321
    SAiNT
    Participant

    there is definitely some silly mistake that you simply don’t see at the moment, probably because you were coding too much.
    this shit happens all the time – you can spend 2 hours to find out that you forgot to close one tag. :(
    the best option is to do another part of the code, or go to sleep. when your mind is fresh you’ll find it in less than a minute.

    #62304
    SAiNT
    Participant

    anyway, put this inside your HTML fine, inside the HEAD tag:


    you can also check this:


    #62263
    tjgriffiths1
    Participant

    Saint! It worked! Brilliant. Really don’t understand why it won’t link through to my stylesheet, but i’ll keep going.

    You guys are awesome. thanks.

    #62238
    SAiNT
    Participant

    actually, i made that code for test purposes only :)
    meaning, if it works inside the HTML, then you have another problem – somehow your CSS file is partially(wtf?) not connected..

    is the CSS file in the root with your HTML index file? if so, you should specify that when you calling for the file:

    (/stylesheet.css)
    the slash before the name means that the document is in the root.
    if that’s the case, i’d say it’s better to specify it.

    but i’ll keep going.
    exactly… you can deal with those things when you have an inspiration to deal with those exact things :-)))

    and here, keep these with you:
    http://www.addedbytes.com/cheat-sheets/css-cheat-sheet/
    http://www.addedbytes.com/cheat-sheets/html-cheat-sheet/

    #62130
    tjgriffiths1
    Participant

    You are a legend. Thank you Saint.

Viewing 12 posts - 1 through 12 (of 12 total)
  • The forum ‘CSS’ is closed to new topics and replies.