Stalingrad Posted August 1, 2011 Share Posted August 1, 2011 Hey! My whole website was deleted at the beginning of the month, so I'm re making the entire site, well.. I'm having a HUGE problem with the CSS. I want the css page to be external. Ih ave a file named style.css here is the EXACT code on the style.css page: <style> banner{ font-size: 30px; font-color: black; font-family: verdana; } top{ font-size: 8px; font-color: red; font-family: verdana; } body{ font-size: 14px; font-color: blue; font-family: verdana; } </style> Now.. my website is PHP based, and I'm having trouble getting it to show up. Here is the page I want the css to work on (well, it will be all pages, but I only have index.php up so far). Here is the EXACT code for index.php (with exeption of my database user/password): <?php include("style.css"); echo "<banner>Welcome to Hangeia!</banner><br><br><top>Testing this!</top><br><br><body>Testing this again!!</body>"; ?> If anybody can please help me, I would really apreciate it, thanks!! Quote Link to comment Share on other sites More sharing options...
ZulfadlyAshBurn Posted August 1, 2011 Share Posted August 1, 2011 remove the <style> & </style> on the style.css and use link href to link it. <link href="style.css" rel="stylesheet" type="text/css"> Quote Link to comment Share on other sites More sharing options...
Stalingrad Posted August 1, 2011 Author Share Posted August 1, 2011 what page dop i use the link on? I already tried that and it just displays the whole .css file... it displays the code. Where do I write that in the index file? thanks! Quote Link to comment Share on other sites More sharing options...
ZulfadlyAshBurn Posted August 1, 2011 Share Posted August 1, 2011 here you go. index.php <html> <head><title> Hello World </title> <link href="style.css" rel="stylesheet" type="text/css"> </head> <body> <?php echo "<banner>Welcome to Hangeia!</banner><br><br><top>Testing this!</top><br><br><body>Testing this again!!</body>"; ?> </body> </html> style.css banner{ font-size: 30px; font-color: black; font-family: verdana; } top{ font-size: 8px; font-color: red; font-family: verdana; } body{ font-size: 14px; font-color: blue; font-family: verdana; } Quote Link to comment Share on other sites More sharing options...
Stalingrad Posted August 1, 2011 Author Share Posted August 1, 2011 thanks! i'll try it ! Quote Link to comment Share on other sites More sharing options...
Stalingrad Posted August 1, 2011 Author Share Posted August 1, 2011 nope that didnt work im getting all of the same font, size and color Quote Link to comment Share on other sites More sharing options...
ZulfadlyAshBurn Posted August 1, 2011 Share Posted August 1, 2011 use style class instead of tags. Quote Link to comment Share on other sites More sharing options...
Stalingrad Posted August 1, 2011 Author Share Posted August 1, 2011 i'[m not quite sure what you mean, but i think I remember putting something other than just <banner> . Do I put <td class=< "banner"> ? I tried that and nothing happened but I think I'm getting closer. Thanks! Quote Link to comment Share on other sites More sharing options...
harryuk Posted August 1, 2011 Share Posted August 1, 2011 You have to link every page you want to use the CSS. Are you linking the two pages the right way round?? And last Question are you using dreamweaver? if not what software are you using?? Quote Link to comment Share on other sites More sharing options...
Stalingrad Posted August 1, 2011 Author Share Posted August 1, 2011 I'm using cpanel to upload my stuff. I do NOT use any program, I create them myself. I'll show you both pages: style.css: banner{ font-size: 30px; font-color: black ;font-family: verdana; } top{ font-size: 8px; font-color: red; font-family: verdana; } body{ font-size: 14px; font-color: blue; font-family: verdana; } and now my index: index.php: <html><head><title> Hello World </title> <link href="style.css" rel="stylesheet" type="text/css"></head><body> <?php echo "<td class=\"banner\">Welcome to Hangeia!</banner><br><br><td class=\"top\">Testing this!</top><br><br><td class=\"body\">Testing this again!!</body>";?> </body></html> othing is working... I had this problem years ago, but I messed around with it and fixed it. I've googled eveyrthing today... nothing is working. thanks! Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted August 1, 2011 Share Posted August 1, 2011 It sounds like a path issue to me. Is the stylesheet in the same directory as the file that is linking to it? Is that directory the document root of the server? Quote Link to comment Share on other sites More sharing options...
harryuk Posted August 1, 2011 Share Posted August 1, 2011 Try putting a # or a . before the CSS name. Quote Link to comment Share on other sites More sharing options...
cssfreakie Posted August 1, 2011 Share Posted August 1, 2011 your missing some stuff and your adding some unnecessary style too. first things first: assign a type attrribute to your style tags like so: <style type="text/css"> ... </style> in case you use styletags that is Also: If you target a class you assign a dot as a prefix like so: .top (generic) If you target an ID you assign a # as a prefix like so #unique (unique element) Besides that have a look at the following (your code adjusted) body{ font-size: 14px; color: blue; // removed the word font- font-family: verdana; } .banner{ font-size: 30px; color: black; // removed the word font- // removed the font-family since it already gets it from the body } .top{ font-size: 8px; color: red; // removed the word font- // removed the font-family since it already gets it from the body } every time you have troubles with css, go to the w3c validator and run it through: http://jigsaw.w3.org/css-validator if you have troubles with mark up run it through the other validator: http://validator.w3.org besides that a decent editor is a must happy coding! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.