Mahesh ALN πŸ‘½ Profile picture
Coming Back.... πŸ”™

Oct 21, 2021, 21 tweets

Confused between boxes and box model πŸ™„πŸ€”

π˜‰π˜°π˜Ήπ˜¦π˜΄ - π˜‰π˜°π˜Ήπ˜¦π˜΄ 𝘳𝘦𝘀𝘡𝘒𝘯𝘨𝘢𝘭𝘒𝘳 π˜‰π˜°π˜Ήπ˜¦π˜΄ 𝘌𝘷𝘦𝘳𝘺𝘸𝘩𝘦𝘳𝘦 πŸ€·β€β™‚οΈπŸ˜…

Let's learn the most important concept 𝑩𝒐𝒙 𝑴𝒐𝒅𝒆𝒍 π’Šπ’ π‘ͺ𝑺𝑺.

Thread πŸ‘‡

The first thing you need to understand is that,

Everything displayed is just a box.

Everything you see on a web page is made up of rectangles boxes.

on a website, you will see all the content is just a combination of boxes,

Arranged on top to, on next to, bottom, or nested in each other.

Header, nav, footer everything made up with boxes.

Usually, we called it HTML elements instead of rectangles boxes.

π˜‰π˜°π˜Ήπ˜¦π˜΄ - π˜‰π˜°π˜Ήπ˜¦π˜΄ 𝘳𝘦𝘀𝘡𝘒𝘯𝘨𝘢𝘭𝘒𝘳 π˜‰π˜°π˜Ήπ˜¦π˜΄ 𝘌𝘷𝘦𝘳𝘺𝘸𝘩𝘦𝘳𝘦 πŸ˜…

Take a look below πŸ‘‡

Code added by me to see all the boxes πŸ‘‡

1️⃣ What is the Box model in CSS?

Whenever you create an HTML element it is wrapped around in a box, and we are able to modify it using CSS.

this box is built with several different layers such as margin, padding, border, and content.

and with the help of CSS, we can manipulate the size, position, and properties of these boxes.

It is used to develop the design and structure of a web page.

2️⃣ Layers of Box Model:-

- Content Area
- Padding
- Border
- margin

Let's talk about each Layer of Box model.

βœ” Content Area:-

The content area contains the real content which is put inside HTML elements such as text, image, etc.

The width and height properties define the width and height of the content box.

Also, you can define the width and height of content with other properties such as,

max-width, min-width, max-height, and min-height set constraints and not a fixed size.

if we didn't define height and width then it will calculate based on content,

But we have also the option to set fixed height and width with the given properties.

take a look below πŸ‘‡

βœ” Padding:-

Padding in CSS refers to the space between the border and the element content.

To set padding on top, right, bottom, and left. we have properties such as

- padding-top
- padding-right
- padding-bottom
- padding-left

The padding shorthand defines all four sides of an element in one declaration.

βœ” Border:-

The border in CSS is between the margin and padding components of the box model.

Usually, we see the border around buttons like this πŸ‘‡

the border shorthand property takes three inputs:

- border size
- border-style : solid/ dashed
- border-color

List of border styles we can use πŸ‘‡

βœ” margin:-

margin is nothing but space between the box and surrounding boxes.

To set the margin on the top, right, bottom, and left. we have properties such as

- margin-top
- margin-right
- margin-bottom
- margin-left

The margin shorthand defines all four sides of an element in one declaration.

This thread does not end here because,

I have something more to share with you so wait for the next thread.

To be continued.. 🧐

If you like this thread, drop a like and retweet, means a lot to me πŸ’›

βœ¨πŸ†β€

Share this Scrolly Tale with your friends.

A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.

Keep scrolling