Curriculum
Course: HTML Basic
Login

Curriculum

HTML Basic

HTML Introduction

0/1

HTML Editors

0/1

HTML Elements

0/1

HTML Attributes

0/1

HTML Headings

0/1

HTML Paragraphs

0/1

HTML Styles

0/1

HTML Formatting

0/1

HTML Quotation

0/1

HTML Comments

0/1

HTML Colors

0/1

HTML Favicon

0/1

HTML Page Title

0/1

HTML Block and Inline

0/1

HTML Iframes

0/1

HTML Java Script

0/1

HTML File Paths

0/1

HTML - The Head Element

0/1

HTML Style Guide

0/1

HTML Entities

0/1

HTML Symbols

0/1
Text lesson

Background Images

HTML Element with Background Images

You can specify a background image for nearly any HTML element.

Example

<p style=”background-image: url(‘image.jpg’);”>

Background Image on a Page

To incorporate a background image into an HTML element, utilize the HTML style attribute along with the CSS background-image property:

Example

<style>
body {
  background-image: url(‘image.jpg’);
}
</style>

Repeat Background Images

Should the background image be smaller than the element, it will automatically tile both horizontally and vertically to fill the entirety of the element’s space.

IMG_3832

Example

</style>

body {
  background-image: url(‘image.jpg’);
  background-repeat: no-repeat;
}
</style>

Background Cover

To ensure a background image fully encompasses an element, adjust the ‘background-size‘ property to ‘cover’. Additionally, by setting the ‘background-attachment‘ property to ‘fixed‘, you can maintain complete coverage of the element by the background image, while preserving the image’s original aspect ratio without any distortion.

Example

<style>
body {
  background-image: url(‘image.jpg’);
  background-repeat: no-repeat;
  background-attachment: fixed;
  background-size: cover;
}
</style>

Background Stretch

To have a background image stretch and fill the entire dimension of an element, you can configure the ‘background-size’ property to ‘100% 100%‘.

IMG_3833

Example

<style>
body {
  background-image: url(‘image.jpg’);
  background-repeat: no-repeat;
  background-attachment: fixed;
  background-size: 100% 100%;
}
</style>