diff --git a/ansi/colour/rgb.py b/ansi/colour/rgb.py
index 13fbc02..6eb1e29 100644
--- a/ansi/colour/rgb.py
+++ b/ansi/colour/rgb.py
@@ -56,7 +56,7 @@ def rgb16(r: int, g: int, b: int) -> str:
     return rgb_reduce(r, g, b, 16)
 
 
-def rgb256(r: int, g: int, b: int) -> str:
+def rgb256(r: int, g: int, b: int, bg: bool=False) -> str:
     """
     Convert an RGB colour to 256 colour ANSI graphics.
 
@@ -79,4 +79,4 @@ def rgb256(r: int, g: int, b: int) -> str:
         colour = sum([16] + [int(6 * float(val) / 256) * mod
                              for val, mod in ((r, 36), (g, 6), (b, 1))])
 
-    return sequence('m', fields=3)(38, 5, colour)
+    return sequence('m', fields=3)(38 if not bg else 48, 5, colour)

diff --git a/test_ansi.py b/test_ansi.py
index a12d704..a15a75e 100644
--- a/test_ansi.py
+++ b/test_ansi.py
@@ -40,6 +40,11 @@ def test_rgb() -> None:
     msg = (rgb256(0xff, 0x80, 0x00), 'hello world', reset)
     assert ''.join(map(str, msg)) == '\x1b[38;5;214mhello world\x1b[0m'
 
+def test_rgb_bg() -> None:
+    from ansi.colour.rgb import rgb256
+    from ansi.colour.fx import reset
+    msg = (rgb256(0xff, 0x80, 0x00, bg=True), 'hello world', reset)
+    assert ''.join(map(str, msg)) == '\x1b[48;5;214mhello world\x1b[0m'
 
 def test_osc() -> None:
     from ansi import osc

RGB background color support

hi!

Adding a switch to  `rgb256(r,g,b, bg=True)` you could return

```
if bg:
    return sequence('m', fields=3)(48, 5, colour)
else:
    return sequence('m', fields=3)(38, 5, colour)
```
test_ansi.py::test_rgb_bg
test_ansi.py::test_import test_ansi.py::test_import_color test_ansi.py::test_fg_bg test_ansi.py::test_sugar test_ansi.py::test_rgb test_ansi.py::test_osc test_ansi.py::test_iterm test_ansi.py::test_add test_ansi.py::test_add_to_string test_ansi.py::test_add_other test_ansi.py::test_empty test_ansi.py::test_erase