Sushree Sangita Jena
Query: 23 / Answer: 21

07th Dec 2017 .

How block elements can be centered with CSS1?


Answers

Pravash Ranjan Das
Query: 22 / Answer: 27

07th Dec 2017 .

Block level elements can be centered by:
 
The margin-left and margin-right properties can be set to some explicit value:
 
 
 
==============================================================================================
BODY {
 
width: 40em;
 
background: fluorescent;
 
}
 
P {
 
width: 30em;
 
margin-right: auto;
 
margin-left: auto
 
}
 
======================================================================================
In this case, the left and right margins will be each, five ems wide since they split up the ten ems left over from (40em-30em). It was unnecessary for setting up an explicit width for the BODY element; it was done here for simplicity.

  •  Information
  • About Forum

    This educational forum is produly developed by betaQsolutions-A leading software company in Odisha. This forum is developed to discuss the educational topics only betweeen the Students, teachers, Parents & Experts. Topic related to Career, Syllabus, Subjects, Questions, Exams etc are allowed to discuss here.

  • Statistics

    Total topics 43 • Total Query 1115 • Total members 247 • Total Answered 1286