freelance84 Posted July 25, 2010 Share Posted July 25, 2010 HTML option 1 <div style="background-color: #FFFFFF;border: 1px solid #333333;height:300px;width:400px;margin-left:auto;margin-right:auto;"> wtg wegt wtg werg werg grw er gw e5g wet grwertrg</div> HTML option 2 <div class="complete"> werg werg werg werg werg wergwer gwer wef fwe fe w</div> html option 1 with the inline css works. option 2 with the css in the style sheet doesn't. The CSS in the style sheet: .complete{ background-color: #FFFFFF; border: 1px solid #333333; height:300px; width:400px; margin-left:auto; margin-right:auto; } I haven't got a clue why option 2 is not working, could anyone help? Quote Link to comment https://forums.phpfreaks.com/topic/208844-css-not-working-in-the-style-sheet/ Share on other sites More sharing options...
wildteen88 Posted July 25, 2010 Share Posted July 25, 2010 How are you referencing your stylesheet? Quote Link to comment https://forums.phpfreaks.com/topic/208844-css-not-working-in-the-style-sheet/#findComment-1090940 Share on other sites More sharing options...
freelance84 Posted July 25, 2010 Author Share Posted July 25, 2010 <link href="css styles sticky.css" rel="stylesheet" type="text/css" /> in the head. The way it is linked cannot be the problem though as there are loads of other things on the page that linked that work. It's just this "complete" class Quote Link to comment https://forums.phpfreaks.com/topic/208844-css-not-working-in-the-style-sheet/#findComment-1090948 Share on other sites More sharing options...
wildteen88 Posted July 25, 2010 Share Posted July 25, 2010 You have spaces in your filename? Try not to add any spaces within filepaths. It is best practice to substitute spaces with either an underscore (_) or a hyphen (-). Alternatively you could use camel case, eg CssStylesSticky.css The link tag should be between the <head></head> tags. It may be helpful if you posted your actual HTML rather than snippets. Quote Link to comment https://forums.phpfreaks.com/topic/208844-css-not-working-in-the-style-sheet/#findComment-1090968 Share on other sites More sharing options...
freelance84 Posted July 26, 2010 Author Share Posted July 26, 2010 wildteen88, thanks. I simply replaced the spaces in the filename with underscores and bingo it worked! It's weird though that all the other references to the .css worked fine (about 25 pages worth!) Eitherway, thanks a bundle, you've solved my problem Quote Link to comment https://forums.phpfreaks.com/topic/208844-css-not-working-in-the-style-sheet/#findComment-1091209 Share on other sites More sharing options...
freelance84 Posted July 26, 2010 Author Share Posted July 26, 2010 I thought i had had solved this problem, with the help of wildteen, but it just occured again. I'm not sure how it resolved its self this time but it did. I was wondering, does the browser store the css stylesheet in its history? This would explain why how sometimes when i make a change it doesn't change on the site. Quote Link to comment https://forums.phpfreaks.com/topic/208844-css-not-working-in-the-style-sheet/#findComment-1091410 Share on other sites More sharing options...
haku Posted July 27, 2010 Share Posted July 27, 2010 It depends on your server settings, but yes, generally css files are cached by the browser. To do a had refresh of your page (i.e. use nothing from the cache, and get everything fresh from the server), hold shift and click the refresh button (or in most browsers you can hold ctrl and click F5, though this doesn't work in at least Safari, maybe other smaller browsers as well). Quote Link to comment https://forums.phpfreaks.com/topic/208844-css-not-working-in-the-style-sheet/#findComment-1091507 Share on other sites More sharing options...
freelance84 Posted July 27, 2010 Author Share Posted July 27, 2010 thanks, that really does explain a few things Quote Link to comment https://forums.phpfreaks.com/topic/208844-css-not-working-in-the-style-sheet/#findComment-1091617 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.