DarkMoonLLC
DarkMoonLLC

Reputation: 27

HTML Background Repeats

I have this issue where I have a very nice background I made in photoshop and when I set as the background in HTML <body background = "images/bg1.png"> its repeats everywhere and looks really retarded. Does anyone know how to stop it from doing this.

Upvotes: 0

Views: 197

Answers (3)

Frederick Marcoux
Frederick Marcoux

Reputation: 138

First, you SHOULDN'T put your background on the <body> tag. This is deprecated since XHTML 1.0.

So to help you, use CSS and put this code:

body {
    background: url('images/bg1.png') no-repeat center center fixed; // or scroll
}

This will place your background in the center of the page and fix it or let it scroll, depending on your code and purpose.

Also, if you want, you can put background-size: 100%; to fill the document with the image. It will be zoomed so you will lost quality. I recommand using a high resolution image for a background.

Upvotes: 4

McGarnagle
McGarnagle

Reputation: 102743

Use the no-repeat CSS property:

<body style="background: url('images/bg1.png') no-repeat">

Upvotes: 2

smang
smang

Reputation: 1207

CSS:

background-repeat:no-repeat;

Upvotes: 2

Related Questions