diff --git a/src/document/html/internal.h b/src/document/html/internal.h
index b85a87273..c299e730d 100644
--- a/src/document/html/internal.h
+++ b/src/document/html/internal.h
@@ -115,6 +115,7 @@ struct html_context {
};
#define html_top ((struct html_element *) html_context->stack.next)
+#define html_bottom ((struct html_element *) html_context->stack.prev)
#define format (html_top->attr)
#define par_format (html_top->parattr)
diff --git a/src/document/html/parser/general.c b/src/document/html/parser/general.c
index 622e5d1fe..4c7c43648 100644
--- a/src/document/html/parser/general.c
+++ b/src/document/html/parser/general.c
@@ -148,7 +148,7 @@ html_apply_canvas_bgcolor(struct html_context *html_context)
if (par_format.bgcolor != format.style.bg) {
/* Modify the root HTML element - format_html_part() will take
* this from there. */
- struct html_element *e = html_context->stack.prev;
+ struct html_element *e = html_bottom;
html_context->was_body_background = 1;
e->parattr.bgcolor = e->attr.style.bg = par_format.bgcolor = format.style.bg;
@@ -364,7 +364,7 @@ html_html(struct html_context *html_context, unsigned char *a,
/* Modify the root HTML element - format_html_part() will take
* this from there. */
- struct html_element *e = html_context->stack.prev;
+ struct html_element *e = html_bottom;
if (par_format.bgcolor != format.style.bg)
e->parattr.bgcolor = e->attr.style.bg = par_format.bgcolor = format.style.bg;