Index: django/utils/html.py
===================================================================
--- django/utils/html.py	(revision 4556)
+++ django/utils/html.py	(working copy)
@@ -38,9 +38,9 @@
     "Returns the given HTML with all tags stripped"
     return re.sub(r'<[^>]*?>', '', value)
 
-def strip_spaces_between_tags(value):
-    "Returns the given HTML with spaces between tags normalized to a single space"
-    return re.sub(r'>\s+<', '> <', value)
+def strip_spaces_between_tags(value, num_spaces=1):
+    "Returns the given HTML with the given number spaces between tags"
+    return re.sub(r'>\s+<', '>%s<' % (' ' * num_spaces), value)
 
 def strip_entities(value):
     "Returns the given HTML with all entities (&something;) stripped"
Index: django/template/defaulttags.py
===================================================================
--- django/template/defaulttags.py	(revision 4556)
+++ django/template/defaulttags.py	(working copy)
@@ -291,12 +291,13 @@
         return df.format(self.format_string)
 
 class SpacelessNode(Node):
-    def __init__(self, nodelist):
+    def __init__(self, nodelist, num_spaces):
         self.nodelist = nodelist
+        self.num_spaces = num_spaces
 
     def render(self, context):
         from django.utils.html import strip_spaces_between_tags
-        return strip_spaces_between_tags(self.nodelist.render(context).strip())
+        return strip_spaces_between_tags(self.nodelist.render(context).strip(), self.num_spaces)
 
 class TemplateTagNode(Node):
     mapping = {'openblock': BLOCK_TAG_START,
@@ -825,8 +826,9 @@
 
 def spaceless(parser, token):
     """
-    Normalize whitespace between HTML tags to a single space. This includes tab
-    characters and newlines.
+    Adjusts whitespace between HTML tags to a given number of spaces, defaulting
+    to a single space if no numeric value given. This includes tab characters
+    and newlines.
 
     Example usage::
 
@@ -840,6 +842,18 @@
 
         <p> <a href="foo/">Foo</a> </p>
 
+    Alternatively, providing a numeric value works as well as in this example::
+
+        {% spaceless 0 %}
+            <p>
+                <a href="foo/">Foo</a>
+            </p>
+        {% endspaceless %}
+
+    This example would return this HTML::
+
+        <p><a href="foo/">Foo</a></p>
+
     Only space between *tags* is normalized -- not space between tags and text. In
     this example, the space around ``Hello`` won't be stripped::
 
@@ -849,9 +863,14 @@
             </strong>
         {% endspaceless %}
     """
+    num_spaces = 1 # default to 1 space between tags
+    bits = token.contents.split()
+    if len(bits) > 1:
+        # User specified number of spaces between tags
+        num_spaces = int(bits[1])
     nodelist = parser.parse(('endspaceless',))
     parser.delete_first_token()
-    return SpacelessNode(nodelist)
+    return SpacelessNode(nodelist, num_spaces)
 spaceless = register.tag(spaceless)
 
 #@register.tag
Index: tests/regressiontests/templates/tests.py
===================================================================
--- tests/regressiontests/templates/tests.py	(revision 4556)
+++ tests/regressiontests/templates/tests.py	(working copy)
@@ -488,6 +488,10 @@
             'spaceless01': ("{% spaceless %} <b>    <i> text </i>    </b> {% endspaceless %}", {}, "<b> <i> text </i> </b>"),
             'spaceless02': ("{% spaceless %} <b> \n <i> text </i> \n </b> {% endspaceless %}", {}, "<b> <i> text </i> </b>"),
             'spaceless03': ("{% spaceless %}<b><i>text</i></b>{% endspaceless %}", {}, "<b><i>text</i></b>"),
+            # {% spaceless %} with optional numeric argument
+            'spaceless04': ("{% spaceless 0 %} <b>    <i> text </i>    </b> {% endspaceless %}", {}, "<b><i> text </i></b>"),
+            'spaceless05': ("{% spaceless 0 %} <b> \n <i> text </i> \n </b> {% endspaceless %}", {}, "<b><i> text </i></b>"),
+            'spaceless06': ("{% spaceless 3 %}<b> <i>text</i> </b>{% endspaceless %}", {}, "<b>   <i>text</i>   </b>"),
 
             # simple translation of a string delimited by '
             'i18n01': ("{% load i18n %}{% trans 'xxxyyyxxx' %}", {}, "xxxyyyxxx"),
Index: docs/templates.txt
===================================================================
--- docs/templates.txt	(revision 4556)
+++ docs/templates.txt	(working copy)
@@ -757,8 +757,9 @@
 spaceless
 ~~~~~~~~~
 
-Normalizes whitespace between HTML tags to a single space. This includes tab
-characters and newlines.
+Adjusts whitespace between HTML tags to a given number of spaces, defaulting
+to a single space if no numeric value given. This includes tab characters
+and newlines.
 
 Example usage::
 
@@ -772,6 +773,18 @@
 
     <p> <a href="foo/">Foo</a> </p>
 
+Alternatively, providing a numeric value works as well as in this example::
+
+    {% spaceless 0 %}
+        <p>
+            <a href="foo/">Foo</a>
+        </p>
+    {% endspaceless %}
+
+This example would return this HTML::
+
+    <p><a href="foo/">Foo</a></p>
+
 Only space between *tags* is normalized -- not space between tags and text. In
 this example, the space around ``Hello`` won't be stripped::
 
