div p { margin-bottom: 10px;} is not working. Not sure what is wrong here.
.p1, .p2 { margin-bottom: 10px; } is works fine, but div p {...} is not working.
body { position: relative; background-color: Royalblue; /*#f0f0f0;*/ margin: 0px; } .div { position: relative; top: 20px; width: 30%; margin: 0 auto; text-align: center; border: 1px solid black; } .p1 { margin: 0; } .p2 { margin: 0; } div p { margin-bottom: 10px; } <body> <div class="div"> <p class="p1">Welcome to Homepage</p> <p class="p2">Lorem Ipsum</p> </div> </body>
.p1has higher specificity than the combined elementsdiv pso that rule takes precedence. The search terms you want are "css specificity"; there are discrete rules which assign "weights" to different selectors to help the browser determine precedence when cascading styles.