# Use CSS-style color specifications in xcolor?

I have colors on my website #eff5f9 and #dfecf7. I would like to also use them in a latex document. Is there a way to use such hexadecimal specifications with xcolor?

I've tried to read the xcolor manual, but have been unable to find an answer there. Googling has not revealed any simple xcolor tutorials.

-

According to http://en.wikibooks.org/wiki/LaTeX/Colors#Color_Models you can simply use \definecolor{orange}{HTML}{FF7F00} to define colors using a CSS-style hexadecimal notation. If you simply want to use a CSS-style color instead of defining a new named one, you can use \color[HTML]{FF7F00}.

-
Thanks. Incidentally, that page won't load for me. FML. –  Marcin May 11 '11 at 20:11
@Marcin: Check your browser and internet connection. I just loaded that page with no problems. –  Loop Space May 11 '11 at 20:13
please note that you have to use big letters. So \definecolor{orange}{HTML}{ff7f00} will not work, \definecolor{orange}{HTML}{FF7F00} will work. And you have to include \usepackage{xcolor}. –  moose Aug 6 '12 at 7:07

Section 2.2 of the xcolor manual lists the various available colour models. One of them is called HTML and it says:

HTML This is a model derived from rgb in order to enable input of color parameters from web pages or CSS files. Therefore, it is not really a color model of its own right, but rather a user interface for convenience. It is worth mentioning that HTML accepts any combination of the characters 0–9, A–F, a–f, as long as the string has a length of exactly 6 characters. However, outputs of conversions to HTML will always consist of numbers and uppercase letters.

This means that whenever an xcolor command allows you to specify a colour model, you can put HTML in for the model to use the HTML syntax. An example is given near the start of Section 2.2:

\textcolor[HTML]{AFFE90}{foo}

(As I typed this, Jannis posted an answer explaining how to do this with the \definecolor command.)

Of course, the colours in your document might not be exactly the same as those on your webpage, but that's due more to the complexity of colour than the xcolor package. Take a look at PDF colour model and LaTeX for more on this.

-