DREAM_MACHINE Posted March 30, 2013 Share Posted March 30, 2013 For some reason, a <div> tag wont use a class. Here is my code: HTML: <div class="mMain"> </div> CSS: .mMain { width: 225px; height: 500px; border: 1px solid #FF6A00; background-color: #FF6A00; margin-left: 250px;} Please help if possible. Link to comment Share on other sites More sharing options...
Mudsaf Posted March 30, 2013 Share Posted March 30, 2013 Code looks fine, but can you confirm that you have linked the css file correctly to page what contains the div element you're using? Link to comment Share on other sites More sharing options...
DREAM_MACHINE Posted March 30, 2013 Author Share Posted March 30, 2013 I have, I actually used a different div with a different class in the same file and it is working fine. Link to comment Share on other sites More sharing options...
newseed Posted April 1, 2013 Share Posted April 1, 2013 Sometimes css don't work because the closing bracket of the previous css is not present. Run it thru the validator. Link to comment Share on other sites More sharing options...
DREAM_MACHINE Posted April 2, 2013 Author Share Posted April 2, 2013 I Did... It said no errors found. Link to comment Share on other sites More sharing options...
Ingolme Posted April 2, 2013 Share Posted April 2, 2013 Check that the stylesheet is linked properly. The <link> tag must have a type and rel attribute. Link to comment Share on other sites More sharing options...
Wolverine Posted April 2, 2013 Share Posted April 2, 2013 Try this:<!DOCTYPE html><html><head><title>mMain</title><style type="text/css">.mMain { width: 225px; height: 500px; border: 1px solid #FF6A00; background-color: #FF6A00; margin-left: 250px;}</style></head><body><div class="mMain"> </div></body></html>and see if it works. Link to comment Share on other sites More sharing options...
newseed Posted April 2, 2013 Share Posted April 2, 2013 Pretty strange on your end. I did not experience any issues in displaying that set of codes. Try changing your class name and see what happens. In rare cases (and I do mean rare) I have had this kind of issue such as yours and I either changed the class name or delete and started a new html file. Of course it doesn't make sense but try it anyway. Link to comment Share on other sites More sharing options...
DREAM_MACHINE Posted April 2, 2013 Author Share Posted April 2, 2013 I figured it out. I forgot to put a doctype and this happened. Thank you all for helping. Link to comment Share on other sites More sharing options...
newseed Posted April 2, 2013 Share Posted April 2, 2013 You post with HTML code indicates a DocType and so we had no clue that your original page did not have it. Glad you figured it out. Link to comment Share on other sites More sharing options...
Ingolme Posted April 2, 2013 Share Posted April 2, 2013 You post with HTML code indicates a DocType and so we had no clue that your original page did not have it. Glad you figured it out.The code was given by a different person. Link to comment Share on other sites More sharing options...
newseed Posted April 2, 2013 Share Posted April 2, 2013 Oh silly me! Thanks. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now