I am a user of the content management system (TYPO3) that does not allow me to add something to the head
of the html document. Is it possible to define a css style sheet and script in the body so that I do not duplicate corresponding styles and javascript everywhere in the html code that I add?

- 8,591
- 7
- 35
- 57
-
1See: http://stackoverflow.com/questions/1642212/whats-the-difference-if-i-put-css-file-inside-head-or-body and: http://stackoverflow.com/questions/6643017/loading-a-script-in-the-body-section – Faust Aug 13 '12 at 20:45
-
@Faust Thanks! Relevant if not duplicate. – Roman Byshko Aug 13 '12 at 21:44
-
`TYPO3` allows you for sure to add something to the `head` of the document. Do you miss the needed privileges? – pgampe Aug 15 '12 at 07:00
-
@pgampe Are you sure? My admin tells me it is impossible. – Roman Byshko Aug 20 '12 at 11:48
-
``page.config.includeCSS.mycssfile = fileadmin/mycssfile.css`` – pgampe Aug 24 '12 at 13:52
-
same for ``includeJS`` and there is also ``page.headerData`` which lets you add any content to the head section. You can even set ``HTTP`` headers via ``page.config.additionalHeaders``. Please check the TypoScript Reference (``TSREF``). – pgampe Aug 24 '12 at 13:55
-
Of course you need to have the ``admin`` priviledge in TYPO3 to edit template records. If you don't, then just ask your admin to include need stylesheets. – pgampe Aug 24 '12 at 13:59
3 Answers
Technically, it's not valid to place a style
tag inside the body, but most, if not all browsers will actually implement it.
I've always been under the impression that a link
tag should be inside the head
according to the specs, but given a quick test, it looks like using a link
tag inside the body
validates as HTML 5, so that might be an option. See Alohci's comment about this below.
And yes, you can place a script
tag inside your body.

- 37,158
- 8
- 76
- 101
-
HTML5 does a whole lot of relabeling things that have always worked as valid. – Brilliand Aug 13 '12 at 22:57
-
1The link element is not valid in body in HTML5 except when it has an `itemprop` attribute, and you are either working to the WHATWG definition of HTML5, or are including the W3C microdata extension spec to the W3C definition of HTML5. – Alohci Aug 13 '12 at 23:26
-
Thanks for the explanation Alohci. I was pretty sure putting a `link` tag inside the `body` wasn't correct, but was surprised when it passed validation. – wsanville Aug 14 '12 at 13:39
You can add a script in the <body>
, but css should be in the <head>
.
Major browsers recognize <style>
in the <body>
, but it's not valid.

- 274,082
- 63
- 437
- 513
Use Content Element
of HTML
type to do that with TYPO3 backend if there is no other possibility.
Of course as suggested in other answers you should not add CSS in the body, so maybe it will be just better to use inline styles for required elements?
<div style="color: red">title</div>

- 55,576
- 10
- 125
- 182