I will be serving 3rd party content to other sites through an iframe. The content will be presented in a table. Is there any way to use internal style sheets where the defintions are defined within the iframe?? I have read that internal style sheets should only be defined in the head section. External css is not an option.
Here is an example of the content that would show inside the iframe.
<STYLE TYPE="text/css">
.className{
background-color: #444444;
}
&l开发者_JAVA百科t;/STYLE>
<table>
<tr>
<td class="className">
Column 1.
</td>
<td>
Column 2.
</td>
</tr>
</table>
Or is the only alternative to use inline css?
iframe content should be complete html/xhtml. What you have listed in your question will work but I can't see a reason not to have full html tags including <head>
.
When you declare an iframe, you should belinking to a complete html file:
<iframe src ="myIframeContents.html">
<p>Your browser does not support iframes.</p>
</iframe>
myIframeContents.html should be treated like any other html file. It should have tags for html, head, body, etc. This means that you can place <style>
tags directly into the <head>
just like you normally would.
myIframeContents.html:
<html>
<head>
<style type="text/css">
.className{
background-color: #444444;
}
</style>
</head>
<body>
<table>
<tr>
<td class="className">
Column 1.
</td>
<td>
Column 2.
</td>
</tr>
</table>
</body>
</html>
that method there will work. tags are supposed to be used in the head of a document, but can appear in other places as well and be local to that branch of the DOM, including iframes
精彩评论