Difference between margin and padding?

Remember these 3 points:

  • The Margin is the extra space around the control.
  • The Padding is extra space inside the control.
  • The Padding of an outer control is the Margin of an inner control.

Demo Image:(where red box is desire control)

When to use margin vs padding in CSS [closed]

From https://www.w3schools.com/css/css_boxmodel.asp

Explanation of the different parts:

  • Content - The content of the box, where text and images appear

  • Padding - Clears an area around the content. The padding is transparent

  • Border - A border that goes around the padding and content

  • Margin - Clears an area outside the border. The margin is transparent

Live example (play around by changing the values): https://www.w3schools.com/css/tryit.asp?filename=trycss_boxmodel

最新文章

  1. javascript判断数字是integer还是float
  2. python 图片爬虫
  3. 用Docker Compose启动Nginx和Web等多个镜像
  4. 大文件下载控件(down2)-示例更新-Xproer.HttpDownloader
  5. [Android]解决ClickableSpan中点击后ListView中item的长按冲突的问题
  6. 分层服务提供者(LSP)
  7. Python 学习开发笔记之IO操作
  8. linux常用查看硬件设备信息命令(转载)
  9. C#中精确计时的一点收获
  10. Android为TV端助力 帧动画
  11. 数据库 -- mysql表操作
  12. HTML语言字符编码
  13. JS笔记(一):基础知识
  14. checkbox选中并通过ajax传数组到后台接收
  15. Sonar理论篇
  16. Android文件的读写
  17. linux内核分析 第八周读书笔记
  18. Solidity 官方文档中文版 2_Ethereum 智能合约介绍
  19. 二、jdk命令之javah命令(C Header and Stub File Generator)
  20. H5安卓端浏览器如何去除select的边框?

热门文章

  1. 一些常见css样式加选择器
  2. Phoenix的jdbc封装
  3. bash shell脚本之查看当前日期以及登陆用户
  4. Marketing Cloud里取得系统contact数目的API
  5. 6.单表的CRUD操作
  6. 17.SpringMVC核心技术-拦截器
  7. 文件 file open函数的打开及 函数的调用
  8. Swift Review总结一:从 Swift Style 开始
  9. 《数据结构与算法之美》 <01>复杂度分析(上):如何分析、统计算法的执行效率和资源消耗?
  10. 学习笔记:安装swig+用SWIG封装C++为Python模块+SWIG使用说明