PC Review


Reply
Thread Tools Rate Thread

background image

 
 
Tony Johansson
Guest
Posts: n/a
 
      29th Nov 2010
Hello!

I have some problem to understand some htl code here.
I want to show a background image that is stored in a file called
computer.bmp
If I use this html code no background image is shown.

<head runat="server">
<title>Untitled Page</title>

<style type="text/css">
background: url(computer.bmp);
font-family: Verdana;
</style>
</head>

But if change the html code to this it works. Note I must use either the
html or body below <style type="text/css">
<head runat="server">
<title>Untitled Page</title>

<style type="text/css">
html,body
{
background: url(computer.bmp);
font-family: Verdana;
}
</style>
</head>

I use IE 6.0.
Can somebody explain why I must use html or body or both below <style
type="text/css"> to makethe background image show.

//Tony


 
Reply With Quote
 
 
 
 
Jason Keats
Guest
Posts: n/a
 
      29th Nov 2010
Tony Johansson wrote:
> Hello!
>
> I have some problem to understand some htl code here.
> I want to show a background image that is stored in a file called
> computer.bmp
> If I use this html code no background image is shown.
>
> <head runat="server">
> <title>Untitled Page</title>
>
> <style type="text/css">
> background: url(computer.bmp);
> font-family: Verdana;
> </style>
> </head>
>
> But if change the html code to this it works. Note I must use either the
> html or body below<style type="text/css">
> <head runat="server">
> <title>Untitled Page</title>
>
> <style type="text/css">
> html,body
> {
> background: url(computer.bmp);
> font-family: Verdana;
> }
> </style>
> </head>
>
> I use IE 6.0.
> Can somebody explain why I must use html or body or both below<style
> type="text/css"> to makethe background image show.
>


The obvious answer is so that the browser knows which css styles to
apply to which tags.

Alternatively, you could style each tag separately, eg:

<body style="background: url(foo1.gif);">

<p style="font-family: Verdana;">Hello, World!</p>

Or, even better, put your stylesheet in a .css file.

And, stop using IE6!
 
Reply With Quote
 
Brian Cryer
Guest
Posts: n/a
 
      30th Nov 2010
"Tony Johansson" <(E-Mail Removed)> wrote in message
news:id038c$alf$(E-Mail Removed)...
> Hello!
>
> I have some problem to understand some htl code here.
> I want to show a background image that is stored in a file called
> computer.bmp
> If I use this html code no background image is shown.
>
> <head runat="server">
> <title>Untitled Page</title>
>
> <style type="text/css">
> background: url(computer.bmp);
> font-family: Verdana;
> </style>
> </head>


You are missing the name of the element that the css is to apply to and a
pair of braces, so your style definition isn't valid. You've put both in in
your second example below. That's why the second works and the first
doesn't.

> But if change the html code to this it works. Note I must use either the
> html or body below <style type="text/css">
> <head runat="server">
> <title>Untitled Page</title>
>
> <style type="text/css">
> html,body
> {
> background: url(computer.bmp);
> font-family: Verdana;
> }
> </style>
> </head>
>
> I use IE 6.0.
> Can somebody explain why I must use html or body or both below <style
> type="text/css"> to makethe background image show.


I think it need only be:

<style type="text/css">
body
{
background: url(computer.bmp);
font-family: Verdana;
}
</style>

I don't know whether its meaningful to apply styles to "html". Either its
meaningless or would (I imagine) have the same effect as applying a style to
the body.
--
Brian Cryer
http://www.cryer.co.uk/brian



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DIV background-repeat background-image? For shadow effect jc Microsoft ASP .NET 1 19th Mar 2008 02:58 PM
User Background desktop image vs. Lockout image Rickles Windows XP General 0 12th Feb 2006 03:38 PM
How to change desktop image loading between WinXP logo, and Background image Sam Lowry Windows XP General 3 13th May 2005 10:14 PM
Combining Ink Strokes with Background Image into a Bit map Image =?Utf-8?B?QWwgQmFocg==?= Microsoft VB .NET 6 21st May 2004 07:26 PM
Export the worksheet background image as an image file - possible? DataFreakFromUtah Microsoft Excel Programming 2 10th Apr 2004 04:49 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:51 AM.