Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is there any specific way to set padding and margins?

I’m a beginner in CSS and I wanted to test my skills, so I took up some projects to build basic websites purely from css and html. However I often got stuck in places, especially when setting up margins, padding, height etc.

How do I determine the exact values of the margin, padding etc.? Is there some mathematical calculation that people do or do you just put in random values and check if they work?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Here are a few ideas that might be helpful.

  • margin: auto -> this can help you quickly center an element without too much hassle
  • flex and grids -> this answer might provide some useful links
  • check out different CSS units -> this answer gives a nice, brief overview
  • this might be beyond what you need, but if you need to do a calculation in CSS, there’s a function for that -> calc()
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading