Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Div width in cm (inch)

Tags:

I need to put in my site div which is exactly 25cm width ( 10 inch) in every display. How I can do it ?

like image 807
Damir Avatar asked Oct 26 '10 11:10

Damir


People also ask

What is the width of a div?

By default a div is a block element, it means its width will be 100% of its container width, and its height will expand to cover all of its children. In case its children has a larger width than the div 's container width, the div itself does not expand horizontally but its children spill outside its boundary instead.

Is a div 100% width by default?

auto automatically computes the width such that the total width of the div fits the parent, but setting 100% will force the content alone to 100%, meaning the padding etc. will stick out of the div, making it larger than the parent. so setting the 'width' to 'auto' would be better? Yes, but that's the default anyway.


1 Answers

You can simply use the cm unit in CSS:

#mydiv { width: 25cm; } 

Note that, as others pointed out, the result still depends on the correct reading of the monitor size by the operating system.

See the spec for more information.

like image 60
Tomas Avatar answered Nov 06 '22 12:11

Tomas