How Can We Help?
-
HTML
-
CSS
- Introduction to CSS
- Before learning CSS?
- SELECTOR
- Example
- Box Model
- Comments
- Colors
- Background Color
- Text Color
- Border Color
- Backgrounds
- Borders
- Margins
- Padding
- Height, Width, and Max-width
- Outline
- Text
- Font Style, Font Size & Shorthand
- Links
- Display and Position
- Lists
- Tables
- Pseudo-classes and Combinators
- Flexbox
- Grid
- Flexbox vs Grid
- Responsive Web Design
- Media Queries
- Responsive Images
- Fluid Layouts
- Transforms, Transitions, and Animations
-
JavaScript
- Introduction to JavaScript
- Hello World
- Syntax
- Variables
- Data Types
- Numbers
- Boolean type
- String
- Objects
- Primitive vs Reference Values
- Arrays
- Arithmetic Operators
- Remainder Operator
- Assignment Operators
- Comparison Operators
- Logical Operators
- if statement
- if else
- if else if
- Ternary Operator
- Object Spread
- Switch case
- While Loop
- do…while Loop
- Loop
- break
- continue
- Functions
- Storing functions in variables
- Anonymous Functions
- Pass-By-Value
- Recursive Function
- Object Methods
- Constructor Function
- this Keyword
- Object Properties
- for…in Loop
- Object.values
- Object.assign
- Class
- Getters and Setters
- Function Type
- Closures
- Arrow Functions
- When You Should Not Use Arrow Functions
- Rest Parameters
- Callbacks
- Promises
- async/await
-
JavaScript DOM
- JavaScript DOM
- getElementById
- getElementsByName
- getElementsByTagName
- getElementsByClassName
- querySelector
- JavaScript Get the Parent Element parentNode
- Getting Child Elements
- JavaScript Siblings
- CreateElement
- appendChild
- JavaScript textContent
- JavaScript innerHTML
- JavaScript innerHTML vs createElement
- Working with Attributes
- JavaScript Style
- Working with Events
-
React
< All Topics
Box Model
The HTML document is considered a series of boxes that can be used to style the layout.
A pictorial representation of the CSS Box Model is shown below.
As you can see, around the actual content, the CSS box model contains Padding, Border, and Margin.
Padding in CSS
The space around the content box. You can specify the size as required.
Border in CSS
The line that separates the padding and margin. You can create dashed line, normal lines, and so on.
Margin in CSS
The space after the border till the end is shown in the image above. You can specify the size as required.
Example
<div class="div1">
Content of div1.
</div>
<div class="div2">
Content of div2.
</div>
In the above code, there are two div tags, each with a different box style.
The CSS applied to the above code is given below.
.div1 {
height:80px;
width:400px;
padding:30px;
border:2px solid #FF3F34;
margin:20px;
background-color:#C4334D;
}
.div2 {
height:40px;
width:500px;
padding:10px;
border:5px dashed #000123;
}
Table of Contents