FADWA FDIWA FADWA FDIWA - 5 months ago 22
CSS Question

Reduce the width of a <div> block using css

This is the page I have created :

enter image description here

I want to reduce the width of the block which has the orange color as a background-color, without using a number in the property width, is there any other method to do that ?

I tried float:left; and it worked but it goes to the left I want the width to be detected automaticly due to the text lenght and in the center of the html page.


Well if you want it to be centered, with an auto width, one option would be to treat it as an inline element.

display: inline;


display: inline-block;

Assuming the parent element has text-align: center, this should be sufficient.