Movatterモバイル変換


[0]ホーム

URL:


Menu
×
See More 
Sign In
+1 Get Certified Upgrade Teachers Spaces Get Certified Upgrade Teachers Spaces
   ❮     
     ❯   

W3.CSS Margins


The w3-margin class adds 16px margin to all sides of an element.


W3.CSS Margin Classes

W3.CSS provides the following margin classes:

ClassDefines
w3-marginAdds a 16px margin to all sides of an element
w3-margin-topAdds a 16px top margin to an element
w3-margin-rightAdds a 16px right margin to an element
w3-margin-bottomAdds a 16px bottom margin to an element
w3-margin-leftAdds a 16px left margin to an element
w3-sectionAdds a 16px top and bottom margin to an element

Margin

Thew3-margin class adds a 16px margin to all sides of an element:

Thew3-margin class adds 16px margin to all sides of an element.

Example

<div class="w3-container w3-margin">
  <p>I have 16px margin on all sides.</p>
</div>
Try It Yourself »

Margin Top

Thew3-margin-top class adds a 16px top margin to an element:

Thew3-margin-top class adds a 16pxtop margin to an element.

Example

<div class="w3-container w3-margin-top">
  <p>I have 16px margin on the top.</p>
</div>
Try It Yourself »


Margin Bottom

Thew3-margin-bottom class adds a 16px bottom margin to an element:

Thew3-margin-bottom class adds a 16pxbottom margin to an element.

Example

<div class="w3-container w3-margin-bottom">
  <p>I have 16px margin on the bottom.</p>
</div>
Try It Yourself »

Margin Left

Thew3-margin-left class adds a 16px left margin to an element:

Thew3-margin-left class adds a 16pxleft margin to an element.

Example

<div class="w3-container w3-margin-left">
  <p>I have 16px margin the left.</p>
</div>
Try It Yourself »

Margin Right

Thew3-margin-right class adds a 16px right margin to an element:

Thew3-margin-right class adds a 16pxright margin to an element.

Example

<div class="w3-container w3-margin-right">
  <p>I have 16px margin the right.</p>
</div>
Try It Yourself »

Sections

Many HTML elements do not have a default top or bottom margin.Such elements will display without a margin between them:

I am Blue

I am Green

Thew3-section class can be used to separate elements.

It adds16px top and bottom margin to any HTML element:

I am Blue

I am Green

Example

<div class="w3-container w3-section w3-blue">
  <h1>I am Blue</h1>
</div>

<div class="w3-container w3-section w3-green">
  <h1>I am Green</h1>
</div>
Try It Yourself »


×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning.
Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness
of all content. While using W3Schools, you agree to have read and accepted ourterms of use,cookies andprivacy policy.

Copyright 1999-2025 by Refsnes Data. All Rights Reserved.W3Schools is Powered by W3.CSS.


[8]ページ先頭

©2009-2025 Movatter.jp