HTML5, CSS3, and JavaScript Fourth Edition

(Ben Green) #1

CHAPTER 1. FIRST WEBPAGE 11


a magnifying lens. Things measured in real pixels keep getting smaller.


This was a problem for webpages because images and other things got
smaller on the screen, making them harder to see.


The Non-Shrinking CSS Pixel.To solve that problem, the CSS commu-
nity came up with a revised definition of pixel. The official CSS definition
is now the width of a “standard resolution” pixel (which means 96 dots per
inch) when viewed at a distance of 28 inches (arms length). So, an item
that is 96px wide should be as wide as an inch on a ruler held at arm’s
length. Scientifically speaking, there are about 47 pixels per degree of par-
allax, looking straight on. A CSS pixel on a billboard would be a lot bigger
than a CSS pixel on an Oculus Rift virtual reality headset.


The bottom line here is that a CSS pixel could actually be many real pixels,
but it will always appear to be the same size.


Exam Question 5 (p.337): How many CSS pixels are in one degree of
direct vision?
Acceptable Answer: 47


That gets rid of the problem of shrinking pixels. The moon viewed from
earth is 24.3 pixels wide.


http://inamidst.com/stuff/notes/csspxby Sean Palmer explains more.


1.3 Seeing Your Webpage


You can probably see your webpage by simply saving it with .html at the end
of the filename, and then double-clicking it on your desktop. Your default
browser will display it.


To share your webpage it must be on a web server. Appendix 19.1.2 (page
199) explains how to put your webpage on a web server.


Your webpage must have a “name” by which people can request it. That
name is called its URL.


1.4 Version Two


We will add some very simple styling.


Insert these lines at the end of your webpage.

Free download pdf