Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using cm/mm on the CSS of a web app that replicates paper interaction is a good practice?

Tags:

html

css

w3c

I am building a web application that interact with documents for later printing. In some points is similar to Google Docs. I am considering using cm/mm on the CSS of my documents pages because it will help me on the document generation. Example:

// A4 size .page {    width: 210mm;    height: 297mm;    margin: 2cm 5cm;  } 
<div class="page">   ... </div> 

What are the main issues of following this approach?

like image 588
Rui Carneiro Avatar asked Apr 30 '13 10:04

Rui Carneiro


People also ask

Can you use cm in CSS?

The so-called absolute units ( cm , mm , in , pt and pc ) mean the same in CSS as everywhere else, but only if your output device has a high enough resolution. On a laser printer, 1cm should be exactly 1 centimeter. But on low-resolution devices, such as computer screens, CSS doesn't require that.

Can you use mm in CSS?

The so-called absolute units (cm, mm, in, pt and pc) mean the same in CSS as everywhere else. A length expressed in any of these will appear as exactly that size (within the precision of the hardware and software). They are not recommended for use on screen, because screen sizes vary so much.

What is HTML CSS and JavaScript called?

HTML is a markup language and CSS is a styling language. JavaScript, however, is a programming language. Hence, they are all web languages, but they perform different jobs.


1 Answers

W3C has a great post on the subject of CSS units. In particular:

cm: Not recommended for screen / recommended for print

The so-called absolute units (cm, mm, in, pt and pc) mean the same in CSS as everywhere else. A length expressed in any of these will appear as exactly that size (within the precision of the hardware and software). They are not recommended for use on screen, because screen sizes vary so much. A big screen may be 60cm (24in), a small, portable screen is maybe only 8cm. And you don't look at them from the same distance.

The only place where you could use pt (or cm or in) for setting a font size is in style sheets for print, if you need to be sure the printed font is exactly a certain size. But even there using the default font size is usually better.

like image 107
Danny Beckett Avatar answered Oct 15 '22 01:10

Danny Beckett