This page gives an introduction to the Range objects. Using these, you can select any part of an HTML document and do something with this information. The most common Range is a user selection.
This page concentrates on getting the user selection and converting this selection to a W3C Range or Microsoft Text Range object, although we'll treat the programmatic creation of Range objects, too.