Question:
HTML and CSS problem : Where is my mistake in the code ?
?
2014-02-14 10:27:03 UTC
I know Im posting this twice , but the answer didn't help me

CSS code :

body{
background-color: black;
}

#CSS{
margin: 0 auto;
width: 500;
height: 1000;
border: 5px solid red;
background: grey;
}

HTML code :







This is content




It appears only the text without all the backgrounds and sh!t . I want to add the CSS into the HTML file . Just to mention that those are who files HTML file - html 1.html and CSS file - CSS.css

Also when I add the CSS code in the HTML file (I hope you will get me) in the "style" tags it works perfectly so I would also want to ask is this ok to do ?
Three answers:
anup sahoo
2014-02-14 10:47:20 UTC
body{

background-color:#000000; /* black background color */

}



#CSS{

margin: 0 auto;

width: 500px; /* need to define unit was missing */

height: 1000px; /* need to define unit was missing */

border: 5px solid #ff0000; /* red */

background:#cccccc; /* grey background */

}



HTML code :



















This is content









If calling external CSS it need to be called within Tag



below website link is the best to learn HTML & CSS
Nik
2014-02-14 18:33:43 UTC
Your not specifying a type on your width and height in CSS.



"px" , "em"



width: 500px;



CSS will just ignore them and the width and height is determined by the size of the content



For a valid HTML document you need a head section in this you need to link your documents together. If your CSS is in a separate file you need to tell the browser this.











Tip:

Don't call your CSS file css.css css is a file format so don't call html files html. Think about this in human terms if it where real life it would be like me calling you by saying Alex Alex.



I call CSS files global.css as it applies to the site and I call the HTML pages what ever they index for home age etc.

------------------------------------------

Looking at your last question don't include special characters in ID's try to keep it to letters only in classes as well. Try to avoid key words in ID's and Classes "css". "hover" etc etc other languages use these as keywords as in the languages use them for their own reasons so using those words will confuse them.
David W
2014-02-14 19:25:30 UTC
and also you need a style link to your css.css file...



The id parameter has nothing to do with linking a class in a css file with an html tag...


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...