What is border in CSS?
- The CSS Border property allow you to set the border around the HTML elements.
- We can use different properties for the border. Like border color, width, style, etc.
- Also, we can make rounded corner border with the help of border-radius.
Border Properties
border-color: This property is used to set the color of the border.
border-radius: This property is used to set the radius of the border corners.
border-style: This border property defines what type of border will be displayed.
Now let's see some border-style values:
Border Style Values
i) dotted: This border style property is used to set a dotted border.
ii) dashed: This property defines a dashed border.
iii) solid: This property define a solid border.
iv) double: This border style property defines a double style border.
v) groove: This border style property defines a 3D grooved border. The effect depends on the border-color value.
vi) ridge: This border style property defines a 3D ridged border. The effect depends on the border-color value.
vii) inset: This property defines a 3D inset border. The effect depends on the border-color value.
viii) outset: It defines a 3D outset border. The effect depends on the border-color value.
ix) none: This border style property is used to define no border.
x) hidden: This border style property defines a hidden border.
What is background in CSS?
- The CSS Background property is used to add background to the HTML elements.
- Using CSS backgrounds you can add background images, and background colors to the HTML elements.
- Now, let's see different way to add backgrounds:
Background Color
- We can add background color using color name, hex value, or RGB value.
- In this example, we will use predefined color names like red, green, blue, purple, orange, etc. to set background color.
Background Image
- We can also add images as a background in HTML elements
- To set images as background we will use the background-image property.
Background Properties
i) background-position: The background-position property is used to set the position of the background.
ii) background-repeat: The background-repeat property is used to set the background repetition.
iii) background-size: The background-size property is used to set size of the background.
iv) background-attachment: The background-attachment property is used to sets whether a background image's position is fixed within the viewport.
v) background-origin: The background-origin property specifies the origin position of the background.
Background Shorthand Property
Code Described in the video