background-size

In this chapter you will learn:

  1. background-size
  2. How to make the background image to cover

background-size

You can specify percentages and pre-defined values for background-image size. The size is then derived from the width and height of the image.

The background-size Values:

ValueDescription
containScales the image, preserving the aspect ratio, to the largest size that can fit.
coverScales the image, preserving the aspect ratio, to the smallest size that can fit.
autoDisplay the image at full size(default).

Set background image size to contain:

Example

HyperText Markup Language (HTML) is the main markup language for displaying web pages and other information that can be displayed in a web browser(From From Wikipedia, the free encyclopedia).

background image to cover

Set background image size to cover:

Example

HyperText Markup Language (HTML) is the main markup language for displaying web pages and other information that can be displayed in a web browser(From From Wikipedia, the free encyclopedia).

Next chapter...

What you will learn in the next chapter:

  1. Definition, default value, CSS version and JavaScript syntax for border
  2. Syntax to create border property and meaning for each of its property value
  3. An example showing how to use border CSS property
  4. How to add a black thick solid border
Home » HTML CSS Tutorial » CSS Reference
background
background-clip
background-color
background-origin
background-position
background-repeat
background-size
border
border-bottom
border-bottom-color
border-bottom-left-radius
border-bottom-right-radius
border-bottom-style
border-bottom-width
border-collapse
border-color
border-left
border-left-color
border-left-style
border-left-width
border-radius
border-right
border-right-color
border-right-style
border-right-width
border-spacing
border-style
border-top
border-top-color
border-top-left-radius
border-top-right-radius
border-top-style
border-top-width
border-width
bottom
caption-side
clear
color
content
counter-increment
counter-reset
cursor
direction
display
empty-cells
float
font
font-family
font-size
font-style
font-variant
font-weight
height
left
letter-spacing
line-height
list-style
list-style-image
list-style-position
list-style-type
margin
margin-bottom
margin-left
margin-right
margin-top
max-height
max-width
min-height
min-width
opacity
outline
outline-color
outline-offset
outline-style
outline-width
overflow
overflow-x
overflow-y
padding
padding-bottom
padding-left
padding-right
padding-top
position
quotes
right
table-layout
text-align
text-decoration
text-indent
text-overflow
text-shadow
text-transform
top
vertical-align
visibility
white-space
width
word-spacing
z-index