The user of the ASP.NET web app I\'m building can select colors for use on some of the elements (e.g. buttons/titles) to facilitate some degree of personalisation.
A hex color code is composed of three intensity values, one for red, one for green and one for blue, with 2 hex digits for each. To determine dark vs. light, simply add the three values together. Smaller numbers would be darker than larger values.
For #010203, adding the RGB values together gives 01+02+03 = 06. That will be darker than #102030 = 60.