CSS Properties
Image CSS properties are used to modify the image's appearance.
width and height
We can use the style attribute to specify the width and height of an image.
Resizing is ideal for large-sized images.
Checking the actual size of the images is important when resizing to determine the new image size ratio.
The width and height attributes always define the width and height of the image in pixels.
border
The CSS border shorthand property allows users to specify the width, style and color of an element’s border.
- border-width
- border-style (required)
- border-color
border style
The border-style property specifies what kind of border to dispay.
The width can be set as a dotted, dashed, solid, double, groove, ridge, inset, outset, none, and hidden.
border width
The border-width property specifies the width of the four borders.
The width can be set as a specific size (in px, pt, cm, em) or by using one of the three pre-defined values: thin, medium, or thick.
border color
The border-color property is used to set the color of the four borders.
The border-color property can have from one to four values.
- top border
- right border
- bottom border
- left border
border radius
The border-radius property is used to add rounded borders to an element.
display and margin
The display property specifies if/how an element is displayed. Giving a value of block on the display property will let the element take the whole line on its own.
The margin property is used to create space around elements. Giving a value of auto to the margin property gives the element equal amounts of spaces on the left and right side making it appear in the center.
float
The CSS float property specifies how an element should float.
The float property is used for positioning and formatting content e.g. let an image float left to the text in a container.
The float property can have left, right, none, or inherit value.
CSS background properties
background image
The background-image property specifies an image to use as the background of an element.
By default, the image is repeated so it covers the entire element.
background repeat
The background-repeat property repeats an image both horizontally and vertically.
The value can be horizontally repeated (repeat-x), vertically repeated (repeat-y), or no-repeat.
background attachment
The background-attachment property specifies whether the background image should scroll or be fixed.
background position
The background-position property is used to specify the position of the background image.
background size
The CSS background-size property allows you to specify the size of background images.
The size can be specified in lengths, percentages, or by using one of the two keywords: contain or cover.
background
The CSS background property sets all the background properties in one declaration.
When using the shorthand property the order of the property values is:
- background-color
- background-image
- background-repeat
- background-attachment
- background-position
Last updated on