css margin -left-right
The margin-left in CSS is the property used to determine the margin to the left of an HTML element. That is, it increases the space between the left edge of that element and the side element or the edge of the container. The value of the margin-left can be a number with a unit of measure (such as pixels, em, rem) or a percentage value, or a special value such as auto.
Example:
Code
< div style = "margin-left: 20px; border: 1x solid black; width: 100px;" >
< p > This message has a margin-left: 20px < / p >
< / div >
In this example, the div box has a left margin of 20 pixels, making the text inside the box 20 pixels away from the left edge of the box.
Additional features:
Negative value:
Negative margin-left can be used, which causes the element to move more to the left than the normal boundary.
Margins: auto:
Applying margin: auto to an element with a defined width will cause the element to be centered horizontally within the container.
Differences from left:
The margin-left is used to determine the distance between the element and the left edge, while the left is used to determine the position of the absolute position.
The margin-right in CSS is the property used to define the right margin of an HTML element. It creates a blank space between that element and the other elements on the right. The value of the margin-right can be a number with a unit of measurement (such as pixels, em, rem) or auto values.
Example of use:
Margin-right: 20px; / / Define the right margin of 20 pixels.
Margin-right: 1.5em; / / Define the right margin 1.5 times the current font size.
Margin-right: auto; / / Let the browser calculate the appropriate right margin.
Difference between margin and padding:
Margin:
Free space on the outside of the element (border).
Paddling:
Free space within an element (between borders and content).
Conclusion:
Margin-right is a CSS feature used to control the outer distance to the right of an HTML element, allowing the placement and spacing between elements on a web page.# Basics made web site














































































































































