Explore Topics

Margins in CSS

Last Updated : 18 Apr, 2025 - Asked By Ashok

css  margins in css 

Answers
2023-11-09 05:03:02

In CSS, margins are used to create space around elements, outside of any defined borders. Margins can be set for the top, right, bottom, and left sides of an element, and they can be specified in various units such as pixels, ems, rems, percentages, and more.

div {

margin-top: 20px;

margin-right: 10%;

margin-bottom: 20px;

margin-left: 10%;

}

2023-11-14 13:07:36

In CSS, margins are used to create space around an element, outside of any defined borders. The CSS margin properties are used to create space around elements, outside of any defined borders. With CSS, you have full control over the margins. There are properties for setting the margin for each side of an element (top, right, bottom, and left). You can specify the margin for each side of an element using the following properties:

  • margin-top
  • margin-right
  • margin-bottom
  • margin-left
Your Answer



Other Resources

Quiz Image
Quiz

Test your knowledge with interactive quizzes.

Interview Questions Image
Interview Questions

Prepare for interviews with curated question sets.

Q&A Image
Q&A

Ask your coding-related doubts and get answers.

Certification Image
Certification

Earn certifications to enhance your resume.

internships Image
Internships

Hands-on projects to improve your skills.

Quiz Image
Quiz

Test your knowledge with interactive quizzes.

Interview Questions Image
Interview Questions

Prepare for interviews with curated question sets.

blog Image
Blogs

Add your technical blogs and read technical topics.

Certification Image
Certification

Earn certifications to enhance your resume.

Q&A Image
Q&A

Hands-on projects to improve your skills.

People Also Asked