預設邊距的寬度是多少?
<body> 的預設邊距在 HTML 中為 8 畫素。它由瀏覽器提供的 user-agent-stylesheet 以畫素為單位定義。某些瀏覽器允許您建立並使用您自己的 user-agent-stylesheet,但如果您正在開發網站,請保持不變。
HTML 中的預設邊距
示例
讓我們看一個簡單的例子。由於此處預設的邊距為 8px,因此我們不會嘗試更改它 −
<!DOCTYPE html> <html> <title>Example</title> <head> <style> body { background: orange; } </style> <body> <h1>Free Resources</h1> <p>We have the following resources for the users:</p> <div id="container"> <ul> <li>Video Courses</li> <li>Notes</li> <li>Interview QA</li> <li>MCQs</li> </ul> </div> </body> </html>
在 HTML 中更改預設邊距
示例
現在,讓我們更改預設邊距 −
<!DOCTYPE html> <html> <title>Example</title> <head> <style> body { background: orange; margin: 25px; } </style> <body> <h1>Free Resources</h1> <p>We have the following resources for the users:</p> <div id="container"> <ul> <li>Video Courses</li> <li>Notes</li> <li>Interview QA</li> <li>MCQs</li> </ul> </div> </body> </html>
您可以輕鬆比較以上兩個示例並找出邊距差異。
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP