Display Flex Positioning - Notes Lyst4717
Display Flex Positioning - Notes Lyst4717
- Day 14
Agenda
▪ CSS Box Model Continued
Padding in CSS: The CSS padding properties are used to generate space
around an element's content. Let’s understand this with an example.
Example:
Index.html:
Box Model:
Here, if you observe the output padding is applied around the region of content
i.e padding-top is 25px, padding-right is 10px, padding-bottom is 15px and
padding-left is 10px. Instead of writing padding-top, padding-right, padding-
bottom and padding-left you can simply write it as padding and mention all four
dimensions as shown below.
index.html:
Box model:
If you specify only one dimension which will be padding-top then remaining three
will also have same padding value. if you specify 2 dimensions which will
padding-top and padding-right then, dimensions specified to padding-top will be
copied to padding-bottom and dimensions specified to padding-right will be
copied to padding-left as shown below.
index.html
Box Model:
As you can clearly see in the boc model dimensions specified for padding-top
gets reflected to padding-bottom and dimensions specified for padding-right gets
reflected to padding-left.
index.html
Output:
Box Model:
In this example, by using border properties we have added border to the table and
padding is applied to each data present in the table. If you observe the last column
present inside the table it is not center aligned, to make it center aligned padding-
left value should be increased as shown below.
Border in css: The border properties allow you to specify how the border of
the box representing an element should look. There are three properties of a
border you can change −
• The border-color specifies the color of a border.
• The border-style specifies whether a border should be solid, dashed line,
double line, or one of the other possible values.
• The border-width specifies the width of a border.
Let us now understand border with an example.
index.html:
Box Model:
In this example, padding and border is applied for the given content is shown
above. Here, padding is 5px, border-width is 3px, border-style is solid and border-
color is red. Instead of specifying border-width, border-style and border-color you
can make use of shorthand property. When using shorthand property the order
should be border-width, border-style and border-color as shown below.
index.html
In the above example all side of the border have same styling, but certainly you
can give different border-style for all the sides as shown below.
index.html
Till now you have seen rectangular border, now we will see how to put
rounded-border.
Example:
Index.html
Output:
index.html:
Output: