A newbie question regarding BACKGROUND color in CSS style - not showing up (SOLVED)

Hello guys!

I’m a newbie when it comes to programing but I hope to learn soon! I have started to learn HTML and CSS and the basic step was to create a CSS style inside HTML with a short text with background but the background color is not showing… Please tell me why and how to correct this issue?

EDIT: Problem solved! I have used a commentary line RIGHT BEFORE the background code in a seperate line and it somehow issued with the background color line… THANK YOU.

<!DOCTYPE HTML>
<html lang="eng">

<head>
	<meta charset="utf-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1"/>
	<title> TOP 5 MOVIES </title>
	<meta name="description" content="LIST OF TOP 5 MOVIES" />
	<meta name="keywords" content="MOVIES, RANKING, TOP" />
	
	<style>
	#container
	{
		width:1000px;
		margin-left: auto;
		margin-right: auto;
	}
	#logo
	{
		background-color: blue;
	}
	</style>
</head>

<body>
	<div id="container">
		<div id="logo">
			<h1> TOP 5 MOVIES </h1>
		</div>
	</div>
</body>
</html>

The background colour works OK for me, if I copy and paste your code.

However, this line is incorrect:

width="100px";

In CSS, that should be

width: 100px;
1 Like

Thank you! I have fixed that line but the background is still white for me, no matter what color I use… Both on Chrome and Edge :confused:

EDIT: When I copy and paste it to NOTEPAD and save it works, but when I save it with NOTEPAD++ it doesn’t… so I must’ve some coding error there? ENCODING: ENCODE in UTF-8 I have…

I’ve copied and pasted your code into an online tester http://webtutorialplus.com/html-code-tester.aspx and it seems fine.

Try reloading the page without cache (usually Ctrl+F5)

1 Like

Thank you guys for replies - the problem was in the line I have previously inserted for myself right above “background-color: blue;”. When I moved my comment AFTER the line, the code worked well. Thanks again everyone!

1 Like

Are you using the right comment format? Comments shouldn’t affect the code.

Within your CSS block you need to use:

/* a CSS comment */

and not

<!--  an HTML comment  -->
3 Likes

Hahah ahhh! That’s why it messes up witht he code! Thank you so much, you’re right again :slight_smile: I still have a lot to learn…

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.