Generate Your Own Playground
Type any CSS property and get a live, editable playground instantly.
.container {
text-align: center;
background-color: #f0f0f0;
padding: 20px;
}
.title {
margin-top: 20px;
font-size: 2em;
color: #333;
}
.description {
font-size: 1.2em;
color: #666;
}
.additional-info {
margin-top: 30px;
font-size: 1em;
color: #444;
}The 'margin-top' property in CSS is used to create space above an element, pushing it downward away from preceding elements. This property can be particularly useful for controlling the vertical spacing in layouts, ensuring that elements are not too close together. By adjusting the 'margin-top' value, you can achieve the desired visual separation between elements.
.container {
display: flex;
}
.box {
background-color: lightblue;
padding: 20px;
margin-right: 20px;
border: 1px solid blue;
}
.box:last-child {
margin-right: 0;
}The 'margin-right' property in CSS is used to create space on the right side of an element. This space can help in positioning elements away from each other, improving the overall layout and readability of the webpage. By adjusting the 'margin-right' value, you can control how much space is added to the right of an element.
.container {
display: flex;
background-color: #f0f0f0;
padding: 20px;
}
.box {
background-color: #4CAF50;
color: white;
padding: 20px;
margin-left: 30px;
}The 'margin-left' property in CSS is used to create space on the left side of an element. This space can push the element away from its neighboring elements, affecting the layout and positioning on the page. By adjusting the 'margin-left' value, you can control how far an element is offset from the left edge of its container or adjacent elements.
.container {
background-color: #f0f0f0;
padding: 20px;
border: 1px solid #ccc;
}
.header {
margin-inline-start: 50px;
color: #333;
}
.description {
color: #666;
}The 'margin-inline-start' property in CSS defines the margin space on the inline start side of an element, which is typically the left side in left-to-right (LTR) languages and the right side in right-to-left (RTL) languages. This property allows for greater flexibility in layout design by adjusting spacing based on the writing direction, improving the responsiveness of web pages.
.container {
display: flex;
justify-content: space-between;
padding: 20px;
background-color: #f0f0f0;
}
.box {
background-color: #4CAF50;
color: white;
padding: 20px;
margin-inline-end: 20px;
}
.box:last-child {
margin-inline-end: 0;
}The 'margin-inline-end' CSS property sets the margin space on the end side of an element in a block container, which is determined by the text direction (left for left-to-right and right for right-to-left). This property is useful for creating responsive layouts that adapt to different writing modes without needing to change the margin values manually.