Sie sind auf Seite 1von 11

HTML Backgrounds

TLE 10 (SPECIALIZATION)
PC OPERATIONS
A. Use Notepad to author an HTML
document.
B. Use basic tags to denote paragraphs,
emphasis or special type.
C. Add images to your document.
HTML background is the HTML attribute used to place pictures in
the background of HTML elements.
Like the bgcolor attribute, background is now deprecated and its
use has been replaced by the use of CSS (Cascading Style
Sheets).
However, this lesson does cover some important aspects of
background elements that do apply to both the deprecated
HTML background and the new CSS backgrounds as well.
By default, your webpage background is white in color.
You may not like it, but no worries. HTML provides you
following two good ways to decorate your webpage
background.

Html Background with Colors


Html Background with Images

The bgcolor attribute is used to control the background


of an HTML element, specifically page body and table
backgrounds.
BACKGROUNDS
The <body> tag has two attributes where you
can specify backgrounds.

The background can be a color or an image.


1
Bgcolor
The bgcolor attribute specifies a background-color for an
HTML page. The value of this attribute can be a hexadecimal
number, an RGB value, or a color name:

<body bgcolor="#000000">
<body bgcolor="rgb(0,0,0)">
<body bgcolor="black">
2 HTML background
Background
The background attribute can also specify a background-
image for an HTML page. The value of this attribute is the
URL of the image you want to use. If the image is smaller
than the browser window, the image will repeat itself until it
fills the entire browser window.

<body background="clouds.gif">
CSS background
<html> <html>
<head> <head>
<title>My First WebPage</title> <title>My First WebPage</title>

<style> <style>
body body
{ {
background-image: url("Tulips.jpg"); background-image: url("Tulips.jpg");
background-size: 1280px 1024px; background-repeat: repeat;
background-repeat: no-repeat; }
}
</style> </style>

</head> </head>
INSERTING IMAGES TO
DOCUMENTS
HTML Images Syntax
In HTML, images are defined with the <img> tag.
The <img> tag is empty, it contains attributes only, and does not
have a closing tag.
The src attribute specifies the URL (web address) of the image:

<img src="url" alt="some_text" style="width:width;height:height;">


HTML Images Syntax

<html>
<body>

<p>If a browser cannot find an image, it will display the alternate text:</p>

<img src="wrongname.gif" alt="HTML5 Icon style="width:128px;height:128px;">

</body>
</html>
Image Floating
Use the CSS float property to let the image float to
the right or to the left of a text:
<img src="smiley.gif" alt="Smiley face" style="float:right;width:42px;height:42px;">

<img src="smiley.gif" alt="Smiley face" style="float:left;width:42px;height:42px;">

Das könnte Ihnen auch gefallen