blogsmith Posted May 25, 2006 Share Posted May 25, 2006 Is it correct that there are 2 ways to make an image a background for a webpage, namely:<body background="clouds.gif">body {background:url("http://photo-url.jpg");Are both methods acceptable, or is one method better than the other? Link to comment Share on other sites More sharing options...
Jack McKalling Posted May 25, 2006 Share Posted May 25, 2006 The first one is depreciated, the second is recommended Link to comment Share on other sites More sharing options...
pulpfiction Posted May 25, 2006 Share Posted May 25, 2006 Both of them will work the same, but when you use CSS then every on page when you use the <body> then this background will apply. but to the above statement <body background="clouds.gif"> will be for that individual page. Link to comment Share on other sites More sharing options...
boen_robot Posted May 25, 2006 Share Posted May 25, 2006 There is a bit more something to that you might need to know for the future. XHTMLs specification doesn't allow backgrounds on the <body> but does allow on the <html> element, or at least, that's what Firefox does when it opens *.xhtml files (and it's not suppose to be a bug either, I checked). So for the sake of browsers supporting the application/xhtml+xml MIME type, it is of best practice to use html {background:url("http://photo-url.jpg");} instead Link to comment Share on other sites More sharing options...
Jack McKalling Posted May 25, 2006 Share Posted May 25, 2006 In short, it is best to place just all styling (everyone) in your stylesheet :)Xhtml is the prefered one over Html with the programmers, so turning over to its strict rules won't be a bad thing. 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