By Sebastiaan de Jonge, published on Tuesday, January 26, 2010 at 22:02

In my opinion, TYPO3 does not generate very pretty HTML output by default. But with some tweaking we can still make something nice out of it! Follow the steps to make your TYPO3 website(s) output clean code.
First of all I start of with cleaning the HTML output as it is. I prefer not to have the default css styled content tags in every headers etc. Just like all content wrappers and comments. To filter out some of these things, we can use the following lines of TypoScript.
# Disable the prefix comments for each CE
page.config.disablePrefixComment = 1
# Clear out the "bodytext" class from all paragraphs (<p></p>)
lib.parseFunc_RTE.nonTypoTagStdWrap.encapsLines.addAttributes.P.class >
# Remove the classes in all headers (H1, H2, H3 etc)
lib.stdheader.stdWrap.dataWrap >
lib.stdheader.3.headerClass >
tt_content.stdWrap.dataWrap >
tt_content.stdWrap.innerWrap.cObject.default {
  10 >
  15 >
  20 >
  30.value = |
# Disable the baseWrap
config.disableBaseWrap = 1
Some extensions supply nice CSS styles, which allow you to quickly set them up. If you however want to restyle everything with your own CSS, don't forget to take it out. Another option is to just merge it with your own stylesheet. If you would remove all these styles, the CSS file that is generated in typo3temp is no longer needed, which saves you 1 HTTP request on each page load. CSS styles have to be unset for each extension that uses them. You can do so by using the following TypoScript code.
plugin.tx_cssstyledcontent._CSS_DEFAULT_STYLE >
plugin.tx_indexedsearch._CSS_DEFAULT_STYLE >
plugin.tx_whateverthenameofyourextensionis._CSS_DEFAULT_STYLE >
Additionally we can unset the default CSS and JavaScript with the following:
config.removeDefaultJS = 1
config.removeDefaultCSS = 1
By default you are able to spam-protect e-mail addresses. Perhaps this will reduce the amount of spam to your address, however I'm not that certain the it has such a big influence on really protecting your address. So if you want to remove this and save some HTML, go ahead and use the following TypoScript in your setup.
config.spamProtectEmailAddresses = 0
The next thing you probably want to get rid of is the noBlur script, you can disable this in your TMENUs but it never seems to go away completely. Read a little more down this article to see how we handle this baby 🙂

Making it all tidy!

Ok so we cleaned up the HTML code that is outputted, but it still looks a little messy in the sourcecode. We can fix this by the using the sourceopt extension. It cleans the final HTML output by removing empty newlines, comments excessive tabs etc. It just creates a nice smoot HTML output. It also gives you the ability to remove the (bloody) noBlur script.Beware to set an additional constant setting if you are using RSS output or something like powermail. Since by default sourceopt will try to reformat all output. Which my result into broken XML or JavaScript (powermail). To work around this problem, simple add this to your constants in your root template:
[globalVar = GP:type > 0]
    sourceopt.enabled = 0
Some people my find it neccesary to remove this from the top of their sourcecode, I think this is simply stupid. You are using an open-source CMS, you have to pay no license of what so ever to use it... So why remove it? You should be proud to use TYPO3 for your website 😉Support TYPO3! Leave the header comment!
Henjo - Wednesday, June 23, 2010 at 09:11

HI Sebastiaan,

nice walkthrough of the steps to take 🙂
Why not use Tidy instead of the sourceopt ext ? Tidy can be set up in the install tool.


Paul - Tuesday, July 13, 2010 at 12:10

Hmmm, tidy works great as long as you don't use powermail. Tidy breaks the javascript validation since it's trying to "htmltidy" a javascript file.

I saw at that this is a known issue for over a year now... 😕

Sebastiaan de Jonge
Sebastiaan de Jonge - Wednesday, July 14, 2010 at 08:14

This was the reason I used this extension. It also has some extras that make it easier to clean up the output, plus configuration through TypoScript.


Alexander - Friday, February 25, 2011 at 00:43

Hello!Do you have some advice for removing typo3temp css from the HTML?

Sebastiaan de Jonge
Sebastiaan de Jonge - Friday, February 25, 2011 at 09:56

Hi Alexander,

It depends a little on what you mean by that. Do you mean to move the CSS physically from the HTML (so to an external file)? Or remove it in general?


Fabian - Tuesday, February 10, 2015 at 22:17

Hi,Thanks for the tips to clean out typo3, I have implemented your suggestions and I now get ">" past the closing div of the content.

Any suggestions

Cheers Fab