HTML Background Images

HTML Background Images
0

#1

Can someone please explain to me why when I run this code the first two css background properties do nothing where as the src that has no tag runs just fine?

<!DOCTYPE html>
<html>
<head>
	<title>TEST</title>
	<style type="text/css">
		.body {
			background-image: url(image/face.jpg);
		}
	</style>
</head>
<body style="background-image: url(image/face.jpg);>
src="image/face.jpg"
</body>
</html>

#2

Of the top of my head, when you first declare the style, you target it with .body - the period indicates it is class. But body is an element, not a class - try it without the period.


#3

This refers to any element with that’s given the 'body' class, not necessarily the <body> element itself (note the dot before body here; you want to remove it).

You’re missing a " after the semicolon.


#4

Also, inside the url function, the file path should be in quotes.


#6

I realised the .body error after posting :stuck_out_tongue:

I hadn’t noticed the " that was missing though, thanks. I’ve now realised the src without an img tag worked because it was being recognised as an extension of the body tag

Thanks guys! That would have bugged me all night :slight_smile: