Home > Article > Web Front-end > How to set left margin in html
How to set the left margin of html: first create a new HTML document; then define a box; then enter the style tag in the head tag; finally enter "position:absolute;" positioning in "#box1" and enter Letf just defines the left margin.
The operating environment of this article: Windows7 system, HTML5&&CSS3 version, Dell G3 computer.
Create a new HTML document, as shown in the picture
Define a box, enter
<div id="box1"></div>
as shown in the picture
Then enter the style tag in the head tag
Define the color and size of the box, enter
width: 100px; height: 100px; background-color: #000000;# in the style tag ##As shown in the picture Press f12 to preview and you can see a black square Return to dw, In #box1, enter position: absolute; for positioning, enter letf to define the left margin, enter left: 100px; to indicate 100 pixels from the left side of the screen, as shown in the figure Finally Press f12 to preview and you can see that the square is farther from the left [Recommended learning:
HTML video tutorial]
The above is the detailed content of How to set left margin in html. For more information, please follow other related articles on the PHP Chinese website!