Forum Moderators: open

Message Too Old, No Replies

including external stylesheet for ad in XHTML page

use external (unknown) css for ads while maintaining valid xhtml

         

jfjet

1:40 am on Jul 27, 2005 (gmt 0)

10+ Year Member



Maybe you all know that in XHTML, <link /> tags are only allowed inside <head></head>.
I have a valid XHTML file, and it contains one or more <script> tags pointing to external(3rd party) javascripts inside <body></body> to load some ads. The ad providers are putting their own <link> tags to link to CSS files for styling their ads.
This case doesn't hurt my XHTML validation since the <link/> is inside the javascript outside of my XHTML, but there are also cases that I have to do "virtual include" of the actual HTML ad content, and that's where the validation issue occurs.
Can someone suggest another way for styling those external ads, while keeping my page XHTML compliant?

encyclo

1:47 am on Jul 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you are trying to include a complete HTML document (with head and body tags and such), then your best bet is to use an
iframe
rather than trying to include them directly. Especially for ads, this will avoid validation problems and, more importantly, parsing problems as spiders or other user agents could get confused by an extra head section or a closing
</html>
.

Or am I misunderstanding the problem?

2by4

2:21 am on Jul 27, 2005 (gmt 0)

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



You can do it, but it's hard. If you're using php, you have to get the remote file, using php file functions, then strip out the <link> part of it before you write it to the page, then write it out to the page, it's not easy to do, but it can be done. Then you would just add a style sheet the normal way in the head tag, the one you stripped out in this case. If I understand you right that is.

jfjet

1:53 pm on Jul 27, 2005 (gmt 0)

10+ Year Member



2by4's suggestion is the only alternative I could think of, but yes, it sounds tedious to do.

Thanks for the suggestions.