Mastering CSS Properties: A Comprehensive Guide to Display, Positioning, and Styling
An Introduction to Common CSS Properties for Styling Web Pages
2 min readApr 26, 2023
CSS is a powerful tool for web designers to style and layout web pages. There are many CSS properties available, each with their own unique purpose. In this article, we’ll explore some of the most commonly used CSS properties and explain what they do.
- Display
Thedisplay
property specifies the type of box that an element generates. This can affect the layout of the page and how elements interact with one another. Common values fordisplay
includeblock
,inline
,inline-block
, andnone
. - Justify-Content
Thejustify-content
property aligns items along the main axis of a flex container. This property is used with thedisplay: flex
property. It has a range of values such asflex-start
,flex-end
,center
,space-between
,space-around
, andspace-evenly
. - Align-Items
Thealign-items
property aligns items along the cross-axis of a flex container. This property is also used with thedisplay: flex
property. It has a range of values such asflex-start
,flex-end
,center
,baseline
, andstretch
. - Padding
Thepadding
property specifies the space between an element's content and its border. It has four values that can be set separately for each side of the element:padding-top
,padding-right
,padding-bottom
, andpadding-left
. - Font-Size
Thefont-size
property sets the size of the text within an element. It can be set in various units, such aspx
,em
,rem
,%
, etc. - Font-Weight
Thefont-weight
property sets the weight (or thickness) of the text within an element. Common values forfont-weight
includenormal
,bold
, andlighter
. - Color
Thecolor
property sets the color of the text within an element. It can be set using a wide range of values, including color names, hexadecimal codes, RGB or RGBA values, and HSL or HSLA values. - Background-Color
Thebackground-color
property sets the background color of an element. It can also be set using a wide range of values, such as color names, hexadecimal codes, RGB or RGBA values, and HSL or HSLA values. - Border
Theborder
property sets the width, style, and color of an element's border. It has three sub-properties:border-width
,border-style
, andborder-color
. - Border-Radius
Theborder-radius
property sets the roundedness of an element's corners. It can be set in pixels or as a percentage of the element's width or height. - Cursor
Thecursor
property sets the type of cursor that appears when the user hovers over an element. Common values includepointer
,default
,text
, andgrab
.
These are just a few of the most commonly used CSS properties. By mastering these properties, you can create beautiful and functional web pages.