# `spaceless`
Use the `spaceless` tag to remove whitespace *between HTML tags*, notwhitespace within HTML tags or whitespace in plain text:
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1
2
3
4
5
6
7</pre></div></td><td class="code"><div class="highlight"><pre>{% spaceless %}
<div>
<strong>foo</strong>
</div>
{% endspaceless %}
{# output will be <div><strong>foo</strong></div> #}
</pre></div></td></tr></table>
This tag is not meant to "optimize" the size of the generated HTML content butmerely to avoid extra whitespace between HTML tags to avoid browser renderingquirks under some circumstances.
Tip
If you want to optimize the size of the generated HTML content, gzipcompress the output instead.
Tip
If you want to create a tag that actually removes all extra whitespace inan HTML string, be warned that this is not as easy as it seems to be(think of `textarea` or `pre` tags for instance). Using a third-partylibrary like Tidy is probably a better idea.
Tip
For more information on whitespace control, read the[*dedicated section*](#) of the documentation and learn howyou can also use the whitespace control modifier on your tags.
- Twig
- Introduction
- Installation
- Twig for Template Designers
- Twig for Developers
- Extending Twig
- Twig Internals
- Deprecated Features
- Recipes
- Coding Standards
- Tags
- autoescape
- block
- do
- embed
- extends
- filter
- flush
- for
- from
- if
- import
- include
- macro
- sandbox
- set
- spaceless
- use
- verbatim
- Filters
- abs
- batch
- capitalize
- convert_encoding
- date
- date_modify
- default
- escape
- first
- format
- join
- json_encode
- keys
- last
- length
- lower
- merge
- nl2br
- number_format
- raw
- replace
- reverse
- round
- slice
- sort
- split
- striptags
- title
- trim
- upper
- url_encode
- Functions
- attribute
- block
- constant
- cycle
- date
- dump
- include
- max
- min
- parent
- random
- range
- source
- template_from_string
- Tests
- constant
- defined
- divisible by
- empty
- even
- iterable
- null
- odd
- same as