Lecture
Automatically Calculating Margin
So, what happens when we set the margin to "auto"?
Auto means 'automatically calculate the margin.'
For example, if you set margin: auto;, it will automatically calculate the left and right margins to be equal, centering the element within its container. This is a common CSS technique for centering elements on a page.
Note that you cannot use the auto value for padding. padding: auto; is not a valid CSS rule.
Padding deals with the internal space of an element, and that internal space is usually determined by the element's size or content.
Lessons in this chapter Β· Creating a Hero Section
- 1. Adding Space to Elements
- 2. Setting Margin Orientation
- 3. Defining Margin and Padding with CSS
- 4. Automatically Calculating Margin
- 5. HTML a Tag
- 6. a Tag target Attribute
- 7. SVG Tag
- 8. Decorating Links
- 9. Flex Layout 1
- 10. Flex Layout 2
- 11. Applying Flex Layout
- 12. Creating a Self-Introduction Section Using Flex
Lecture
AI Tutor
Design
Upload
Notes
Favorites
Help