MichaelChirico MichaelChirico - 8 months ago 59
Markdown Question

Setting bgcolor in markdown

I want to set the page

through markdown.

Is there any way besides explicitly including, say,
<body bgcolor="#336655">
in the
file? In particular, this seems to be implemented incorrectly. E.g. the following minimal file:

% Page Title

<body bgcolor="#336655">

## Some Body

Produces the following HTML file (through
pandoc -s -o test.html test.md

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="generator" content="pandoc" />
<title>Page Title</title>
<style type="text/css">code{white-space: pre;}</style>
<div id="header">
<h1 class="title">Page Title</h1>
<body bgcolor="#336655">
<h2 id="some-body">Some Body</h2>

In particular, the
tag I included did not overwrite the main
tag produced, as I'd intended (closing with
in the markdown doesn't change this).

Placing the
tag prior to the
% Page Title
line shuts down the interpretation of that line as the page title -- it just formats as
% Page Title
in plain text.

Is there no way to control the overall page background in markdown?


You should change the pandoc template for that and insert the needed CSS. Don't do styling in HTML, it's not the 90s anymore...

$ pandoc -D html > template.html

edit it to include:

<style type="text/css">
  body {
    background-color: #336655;


$ pandoc -s --template template.html -o output.html input.md