Pratham Profile picture
14 May, 17 tweets, 4 min read
Box Model

Everything on a website is a box. Therefore it is quite important to understand the box model concept in web development but it is confusing. Let's see some hidden facts about it in this thread

🧵 👇🏻
When laying out a document, the browser's rendering engine represents each element as a rectangular box. You can visualize it by adding some solid in any element.

You can manipulate this box using the basic standards of CSS like color, border, background etc.

{ 02 / 17 }
Every box comprised of four parts

- content dimensions
- padding
- border
- margin

Although outline is not considered as the part of box model but we can talk little bit about it later on this thread.

{ 03 / 17 }
The content area contains the real content in form of text, videos, images. The dimensions of the content area is defined by the height and width CSS property.

{ 04 / 17 }
Moving further, the next area we have in box is padding area. Basically padding is the empty area between content edge and border.

It is generally used to make the content looks good which eventually increase the readability of content.

{ 05 / 17 }
The padding area is covered with the same color as of element's background color hence we can say that padding area is visible.

{ 06 / 17 }
Moving onto "Border area", border is some fixed thinckness separation between padding and margin. The thickness of the borders are determined by the border-width and shorthand border properties.

{ 07 / 17 }
The border witdth is also counted in the total dimenstion of the box. For example

width: 300px;
padding: 100px;
border-width: 10px;

then the total width of the box is 520px

{ 08 / 17 }
We have noticed that padding and border can increase the dimentions of the box. In order to prevent it and merge the thickness of padding and border within the element's fixed dimensions, we can use one single property know as box-sizing

{ 09 / 17 }
box-sizing: border-box;

The width and height properties include the content, padding, and border, but do not include the margin. Note that padding and border will be inside of the box.

{ 10 / 17 }
The margin area, bounded by the margin edge, extends the border area to include an empty area used to separate the element from its neighbors. Its dimensions are the margin-box width and the margin-box height.

The margin area is transparent.

{ 11 / 17 }
Let me tell you the unique concept of margin in CSS which probably you haven't heard yet... 👇🏻

{ 12 / 17 }
The margin collapsing

The top and bottom margins of blocks are sometimes combined (collapsed) into a single margin whose size is the largest of the individual margins (or just one of them, if they are equal), a behavior known as margin collapsing.

{ 13 / 17 }
Although there are three main cases in which margin collapsing occurs. They are

1. Adjacent sibling's margin are collapsed
2. Empty blocks margin are generally collapsed
3. No content separating parent and descendants

Read more about it here: geeksforgeeks.org/what-are-the-r…

{ 14/17 }
Difference between border and outline are generally confusing. Let's talk little bit about it.

An outline is a line that is drawn around elements, OUTSIDE the borders, to make the element "stand out". outline styling is exactly same as border.

{ 15 / 17 }
The difference between outline and border

- Outline is drawn outside the element's border
- Outline may overlap other content
- Outline is not the part of element's dimensions
- Outline don't effect dimenstions

{ 16 / 17 }
I think that's pretty much it for this thread. If you like it, share it with your connections. It means a lot to me ❤️

Peace out 😉

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Pratham

Pratham Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @Prathkum

15 May
You can check out these websites if you're learning HTML, CSS and JavaScript 🧵...
HTML 🧱

1. Learn HTML
learn-html.org

2. HTML best practice
hail2u.github.io/html-best-prac…

3. HTML reference
htmlreference.io
CSS 🎨

1. CSS reference
cssreference.io

2. Learn to code
learn.shayhowe.com

3. CSS layout
learnlayout.com

4. CSS tutorial
csstutorial.net

5. Learn about colors
hexinvaders.com

6. Learn gird layout
griddy.io
Read 4 tweets
15 May
Are you planning to learn CSS for adding some cool styling in your website?

In this thread, I'm covering all the basics and proper plan you need to know in order to getting started with CSS.

🧵 👇🏻 Image
We need to know the importance of CSS first. Why CSS?

Well I guess CSS is the only language that add some visuals in website. Without CSS, Without it, websites would still be plain text on white backgrounds.

{ 02 / 17 }
Let's compare a website with and without CSS

Image 1: With CSS
Image 2: Without CSS

{ 03 / 17 } ImageImage
Read 17 tweets
15 May
5 best color palette for every web developer and designer 🎨

🧵👇 Image
1. Color hunt

- Color Hunt is a free and open platform for color inspiration with thousands of trendy hand- picked color palettes

🖇️ colorhunt.co Image
2. Adobe color wheel

Explore and create accessible color palettes using color wheel, in variety of color variations and contrast levels. It will tell you automatically if two colors are not accessible

🖇️ color.adobe.com/create/color-a… Image
Read 6 tweets
14 May
Neumorphism is a trendy UI style nowadays. It is worth noting that neumorphism is not a replacement for flat design style, but an addition to app user interface design

Let's create a neumorphic form using few simple CSS steps

A thread 🧵
Neumorphic design is another UI design that has become popular these days.

Making neumorphic effect is actually pretty easy using only just CSS box-shadow

We'll be creating a neumorphic form in steps 🔽
STEP 1:

Place a light source(virtually) on screen. In this example I'm considering that my light source is placed top left corner of the screen
Read 13 tweets
14 May
5 amazing websites for developers that can save you a lot of time 🧵👇🏻
1️⃣ Oh shit, Git!

Check out this great website. Some bad situations and often mistakes that we make while working with Git. You'll probably find your answer here

🔗 ohshitgit.com
2️⃣ Check SEO

Get free on page SEO audit report. Find the mistakes in technical SEO for specific URL.

🔗 sitechecker.pro
Read 6 tweets
13 May
Creating CSS arts is a good way to master CSS. Here are some resources and tips that will take your CSS skills to the next level 🚀

🧵👇🏻
Trust me, CSS art looks hard but they are not so tough they seem.

First things first, good color contrast is the number characterstic of a good website. Similarly color combinations makes your art good.
People with visual impairment preceive colors in different way. For example, here is how the dark red color is seen by people with monochromacy, dichromacy, and trichromacy

Hence picking up right color combinations is the most important part
Read 12 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!

:(