Forum Moderators: not2easy

Message Too Old, No Replies

including css file outside of head tags

         

wheel

3:57 am on May 16, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have some pages where I want to include a css file outside the head tags.

Seems like I can either just dump the css file inside some < style > tags, or add a < link > tag except everything I've read on this indicates those must happen inside the head tags. In this case I don't have access to the head tags (it's inside a CMS).

Should I just go with a regular css link tag, but within the body tags? Or is there a better way?

Marshall

4:51 am on May 16, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Is there a reason you can't put it in the <HEAD>?

Xapti

7:05 am on May 16, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The CMS should let you edit the stylesheet(s) it includes... you hsould copy and paste it into there if it only lets you use one, or add it if it will let you.

Things will work if you put the style tags in the body though... I just don't know how proper it is.

[edited by: Xapti at 7:06 am (utc) on May 16, 2007]

Setek

7:14 am on May 16, 2007 (gmt 0)

10+ Year Member



Is there a reason you can't put it in the <HEAD>?

Because it's CMS-driven, they will only probably have access to the content section.

Listen, there's not all that much wrong with having a

<style>
element in the content, besides it not validating I believe. It will work. I've never tried using a
<link />
for anything outside of
<head>
, but I have had to use a
<style>
outside of it, and it works fine :)

Robin_reala

8:32 am on May 16, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The technical reason why it's not a good idea is that it slows the whole page down by breaking incremental rendering - I believe browsers are forced to start CSS rendering over from scratch if they find a <style> element in the body as the CSS could apply to elements they've already rendered.

wheel

12:32 pm on May 16, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I appreciate it's not a good idea, but if it works, that's the method for me :).

The CMS doesn't allow me to insert tags into the head section, and each of the many pages I'm inserting have their own page-specific css.

Does anyone know if the <link> tag will work outside the head tags? I'd rather do it that way than include the entire css file in the page so that spiders don't have to download it.