Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Regular Coder
    Join Date
    Jul 2011
    Posts
    172
    Thanks
    64
    Thanked 2 Times in 2 Posts

    Why css does not work (example from a book)?

    Code:
    <html>
    <head>
    <title>Starbuzz Coffee</title>
     <style type=”text/css”>
     body { 	
    	background-color: #d2b48c;
    	margin-left: 20%;
    	margin-right: 20%;
    	border: 1px dotted gray;
    	padding: 10px 10px 10px 10px;
    	font-family: sans-serif;
    		}
     </style>
     </head>
     <body>
    <h1>Starbuzz Coffee Beverages</h1>
    <h2>House Blend, $1.49</h2>
    <p>A smooth, mild blend of coffees from Mexico, Bolivia and
    Guatemala.</p>
    <h2>Mocha Caffe Latte, $2.35</h2>
    <p>Espresso, steamed milk and chocolate syrup.</p>
    <h2>Cappuccino, $1.89</h2>
    <p>A mixture of espresso, steamed milk and milk foam.</p>
    <h2>Chai Tea, $1.85</h2>
    <p>A spicy drink made with black tea, spices, milk and honey.</p>
    </body>
    </html>
    Copy and try:

    http://www.w3schools.com/html/tryit....=tryhtml_intro

  • #2
    Regular Coder
    Join Date
    Jul 2011
    Posts
    105
    Thanks
    12
    Thanked 1 Time in 1 Post
    What?
    Try to keep a straight face whilst considering the following question:

    "How do I download the internet?"

  • #3
    Regular Coder
    Join Date
    Jul 2011
    Posts
    172
    Thanks
    64
    Thanked 2 Times in 2 Posts
    http://joliett89.comli.com/

    No background color, formatting etc...

  • #4
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,662
    Thanks
    41
    Thanked 189 Times in 188 Posts
    your "s are screwed up... copy/paste it to an editor that applies colors; they show it all messed up... also if you save it as .html and open in chrome and inspect element you can see bc the "s are screwed up it changes it to <style type=""text/css"">... sorry, to direct you more, it is the "s in your style tag

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE

  • #5
    Regular Coder
    Join Date
    Jul 2011
    Posts
    172
    Thanks
    64
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by alykins View Post
    your "s are screwed up... copy/paste it to an editor that applies colors; they show it all messed up... also if you save it as .html and open in chrome and inspect element you can see bc the "s are screwed up it changes it to <style type=""text/css"">... sorry, to direct you more, it is the "s in your style tag
    Not sure what you mean. I run http://validator.w3.org/ and it did not find anything either (not in the code above itself) ...

    I looked at the code in Notepad ++ and <style type=”text/css”> "type" is red and "text" is orange if that means anyting ...
    Last edited by joliett89; 07-17-2011 at 05:07 PM.

  • #6
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,662
    Thanks
    41
    Thanked 189 Times in 188 Posts
    doesn't mean much to me at all... i dont use that editor. But i copy/pasted your code and saved it as .html... then i viewed in browser and inspected element and instead of it saying <style type="text/css">..... it said <style type=""text/css"">.... so i went back and deleted the "s and typed them in manually from keyboard and it worked fine. also notice how your "s in the style are not straigh "up and down" they are slanted.. you need to use the keystroke "s

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE

  • #7
    Regular Coder
    Join Date
    Jul 2011
    Posts
    172
    Thanks
    64
    Thanked 2 Times in 2 Posts
    Sorry, but I dont know what you mean. I have Core FTP (free program) and I just login to the server and then get to index.html file and right click on to edit. It is using notepad so all the letters are the same, just like any other text file that I have on my hard drives. I changed all the "s" letters within <style> and </style> tags, just in case, but that dont make no difference. This is as simple as it gets, but I honestly dont know how to get it to work (I've been working on more complex websites etc).

    Website is suppose to look like that: http://joliett89.comli.com/example.jpg
    Last edited by joliett89; 07-17-2011 at 05:26 PM.

  • #8
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,662
    Thanks
    41
    Thanked 189 Times in 188 Posts
    are you saving it as a .html file? or are you trying to view it on w3schools in browser "text editor"? All i did was copy/paste it, and then replace the "s.... it works fine for me. I am not seeing an issue

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE

  • #9
    Regular Coder
    Join Date
    Jul 2011
    Posts
    172
    Thanks
    64
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by alykins View Post
    are you saving it as a .html file? or are you trying to view it on w3schools in browser "text editor"? All i did was copy/paste it, and then replace the "s.... it works fine for me. I am not seeing an issue
    Yes. It is index.html. Doesn't work in Chrome either.

  • #10
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,662
    Thanks
    41
    Thanked 189 Times in 188 Posts
    i don't really know what to tell you... here is the code...

    Code:
    <html>
    <head>
    <title>Starbuzz Coffee</title>
     <style type="text/css">
     body { 	
    	background-color: #d2b48c;
    	margin-left: 20%;
    	margin-right: 20%;
    	border: 1px dotted gray;
    	padding: 10px 10px 10px 10px;
    	font-family: sans-serif;
    		}
     </style>
     </head>
     <body>
    <h1>Starbuzz Coffee Beverages</h1>
    <h2>House Blend, $1.49</h2>
    <p>A smooth, mild blend of coffees from Mexico, Bolivia and
    Guatemala.</p>
    <h2>Mocha Caffe Latte, $2.35</h2>
    <p>Espresso, steamed milk and chocolate syrup.</p>
    <h2>Cappuccino, $1.89</h2>
    <p>A mixture of espresso, steamed milk and milk foam.</p>
    <h2>Chai Tea, $1.85</h2>
    <p>A spicy drink made with black tea, spices, milk and honey.</p>
    </body>
    </html>
    and attached is screen shot in chrome
    Are you using some sort of international keyboard or something?
    Attached Thumbnails Attached Thumbnails Why css does not work (example from a book)?-delete.jpg  

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE

  • Users who have thanked alykins for this post:

    joliett89 (07-17-2011)

  • #11
    Regular Coder
    Join Date
    Jul 2011
    Posts
    172
    Thanks
    64
    Thanked 2 Times in 2 Posts
    I copied your code and it is working now. Thanks. I dont know what the h*** was wrong with it...

    I initially copied the code from an e-book with a little different fonts etc (Pdf). Maybe that was the reason why it was not working. I dont know...

    Code:
     border: 1px dotted gray;
    This part still aint working anyway I got Explorer 8, the newest Chrome and a US Laptop
    Last edited by joliett89; 07-17-2011 at 05:41 PM.

  • #12
    New Coder
    Join Date
    Feb 2011
    Posts
    12
    Thanks
    1
    Thanked 1 Time in 1 Post
    If you inspect it in FireBug or any other browser debugger (not a site like the w3 one you linked, I do not trust that), you can see that your line for declaring your CSS is showing this:
    Code:
    <style type="”text/css”">
    body {
    background-color: #d2b48c;
    margin-left: 20%;
    margin-right: 20%;
    border: 1px dotted gray;
    padding: 10px 10px 10px 10px;
    font-family: sans-serif;
    }
    </style>
    Now if you look, you will see it says ""Text/CSS"", you want it to say "Text/CSS". So inside your HTML file, make sure there are only one set of quotes surrounding the Text/CSS declaration.

  • Users who have thanked leetvivi for this post:

    joliett89 (07-17-2011)

  • #13
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,662
    Thanks
    41
    Thanked 189 Times in 188 Posts
    Quote Originally Posted by joliett89 View Post
    I copied your code and it is working now. Thanks. I dont know what the h*** was wrong with it...
    the "s... that is the only thing i changed.

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE

  • #14
    Regular Coder
    Join Date
    Jul 2011
    Posts
    172
    Thanks
    64
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by leetvivi View Post
    Now if you look, you will see it says ""Text/CSS"", you want it to say "Text/CSS". So inside your HTML file, make sure there are only one set of quotes surrounding the Text/CSS declaration.
    I checked this part ealier. It is showing in "View source" in IE8:

    Code:
    <style type="text/css">
     body { 	
    	background-color: #d2b48c;
    	margin-left: 20%;
    	margin-right: 20%;
    	border: 1px dotted gray;
    	padding: 10px 10px 10px 10px;
    	font-family: sans-serif;
    		}
     </style>

  • #15
    New to the CF scene
    Join Date
    Jul 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    where you took these quotes (””)?


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •