0

When the css is embedded in the head section it works fine, but when it is in a different file, it just doesn't modify my html file. This is very frustrating. Any help please

<!DOCTYPE html>

<html lang="en">
<head>  
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> The Treasure Island </title>
<link rel="stylesheet" href="/~hsono1/css/paged_media.css" />

</head>

<body>

    <header>
        <img src="island3.gif" alt="Island" width="500"/>
        <h1>The Treasure Island</h1>
        <h2>By Robert Louis Stevenson</h2>
        <hr>
    </header>       

    <div>


        <h2>Table of Contents</h2>


        <ul>
            <ol><a href="#C1">Chapter 1</a></ol>
            <ol><a href="#C2">Chapter 2</a></ol>
            <ol><a href="#C3">Chapter 3</a></ol>
            <ol><a href="#C4">Chapter 4</a></ol>
            <ol><a href="#C5">Chapter 5</a></ol>
            <ol><a href="#C6">Chapter 6</a></ol>
            <ol><a href="#C7">Chapter 7</a></ol>
            <ol><a href="#C8">Chapter 8</a></ol>
            <ol><a href="#C9">Chapter 9</a></ol>
            <ol><a href="#C10">Chapter 10</a></ol>



        </ul>


        <hr>




        <h2>Chapter 3</h2>
        <h3>The Black Spot</h3>     
        <p>ABOUT noon I stopped at the captain’s door with some cooling drinks and medicines. He was lying very much as we had left him, only a little higher, and 
            he seemed both weak and excited. “Jim,” he said, “you’re the only one here that’s worth anything, and you know I’ve been always good to you. Never a month 
            but I’ve given you a silver fourpenny for yourself. And now you see, mate, I’m pretty low, and deserted by all; and Jim, you’ll bring me one noggin of rum, 
            now, won’t you, matey?” “The doctor—” I began. But he broke in cursing the doctor, in a feeble voice but heartily. “Doctors is all swabs,” he said; “and 
            that doctor there, why, what do he know about seafaring men? I been in places hot as pitch, and mates dropping round with Yellow Jack, and the blessed land 
            a-heaving like the sea with earthquakes—what do the doctor know of lands like that?—and I lived on rum, I tell you. It’s been meat and drink, and man and 
            wife, to me; and if I’m not to have my rum now I’m a poor old hulk on a lee shore, my blood’ll be on you, Jim, and that doctor swab”; and he ran on again 
            for a while with curses. “Look, Jim, how my fingers fidges,” he continued in the pleading tone. “I can’t keep ‘em still, not I. I haven’t had a drop this 
            blessed day. That doctor’s a fool, I tell you. If I don’t have a drain o’ rum, Jim, I’ll have the horrors; I seen some on ‘em already. I seen old Flint in 
            the corner there, behind you; as plain as print, I seen him; and if I get the horrors, I’m a man that has lived rough, and I’ll raise Cain. Your doctor 
            hisself said one glass wouldn’t hurt me. I’ll give you a golden guinea for a noggin, Jim.” He was growing more and more excited, and this alarmed me for 
            my father, who was very low that day and needed quiet; besides, I was reassured by the doctor’s words, now quoted to me, and rather offended by the offer 
            of a bribe. “I want none of your money,” said I, “but what you owe my father. I’ll get you one glass, and no more.”   continued...      </p>

        <hr>




    </div>

    <footer>

    <p>&copy; 2013 Hans Sono</p>
    <p><a href="http://validator.w3.org/check?       uri=http%3A%2F%2Fserver.csmcis.net%2F~hsono1%2Fcis127%2Fconversion1.html">Validate this page</a></p>

    </footer>


</body>


</html>

css file

html {
margin: 0;
font: 10pt/1.56 Gill Sans, Gill Sans MT, Verdana,"Lucida Grande", "Lucida         Sans",Helvetica, Arial, sans-serif;
}

body {
background: red;
margin: 0 0 0 0;
margin: 0 0 0 20%;
width:700px;

}

p {

margin-left: 3em;
}

I have both files on the right locations .

8
  • 3
    My bet is the style sheet is not in the right location. Check out your browser's developer tools' "Net" tab to see whether it is getting loaded at all Commented Nov 19, 2013 at 4:00
  • 2
    What happens when you load "/~hsono1/css/paged_media.css" into your browser relative to the base path of your html file? Commented Nov 19, 2013 at 4:01
  • sidenote: you mixed up HTML 4.01 and HTML 5 header syntax. Commented Nov 19, 2013 at 4:01
  • 2
    @ShivanRaptor It looks like fine HTML5 to me, except that <meta charset="" /> is preferred. Commented Nov 19, 2013 at 4:02
  • You are right. But i dont know how to fix it. When I have the css file on "paged_media.css" on my hard drive, it works fine. However, when I use the location fo the server the server "/~hsono1/css/paged_media.css" , it doesnt work. Commented Nov 19, 2013 at 4:03

1 Answer 1

1

This link is very suspicious.

/~hsono1/css/paged_media.css

My guess is you want

/hsono1/css/paged_media.css

(without the tilde).

The tilde (~) is used on some platforms to indicate the root of the virtual directory and is automatically resolved by the server. It has no meaning to the browser.

The way to check is to paste it directly into the brower's address bar right after the domain. For example, if your page is at

http://MyServer.com/hsono1/MyPage.html

then the paste in

http://MyServer.com/~hsono1/css/paged_media.css

or

http://MyServer.com/hsono1/css/paged_media.css

and see what you get back.

Sign up to request clarification or add additional context in comments.

3 Comments

Mm, the tilde is a standard (written? unwritten? Not sure) for user directories (like /~John/)
Huh, never ran across that before... Is that a Linux thing?
Yeah, I think so. (Unix / Linux)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.