How to set left margin in css

青灯夜游
Release: 2023-01-06 11:12:37
Original
23480 people have browsed it

How to set the left margin in css: 1. Use the margin-left attribute to set the left margin of the element. The syntax format is "margin-left:margin value;"; 2. Use the padding-left attribute. You can set the left padding of the element with the syntax format "padding-left:margin value;".

How to set left margin in css

The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.

1. Use margin-left to set the left margin

The margin-left attribute sets the left margin of the element.

Note: Negative values are allowed.

Attribute value:

Value Description
auto The left margin set by the browser.
length Define a fixed left margin. The default value is 0.
% Defines the left margin as a percentage based on the total width of the parent object.

Example:

     

这个段落没有指定左边距。

这个段落带有指定的左外边距。

Copy after login

How to set left margin in css

2. Use padding-left to set the left inner margin

Thepadding-left attribute sets the left padding of an element.

Note: Negative values are not allowed.

Attribute value:

Value Description
length Specifies a fixed left padding value in specific units, such as pixels, centimeters, etc. The default value is 0px.
% Defines a percentage left padding based on the width of the parent element. This value will not work as expected in all browsers.

Example:

     

这个段落没有指定左边距。

这个段落带有指定的左内边距。

Copy after login

How to set left margin in css

Learning video sharing:css video tutorial

The above is the detailed content of How to set left margin in css. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
css
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!