The error is coming because you are putting the <style>
inside <div>
. Do not do that. It is better to move that code to internal or separate external CSS.
External CSS is preferred because it increases the reusability.
The error is coming because you are putting the <style>
inside <div>
. Do not do that. It is better to move that code to internal or separate external CSS.
External CSS is preferred because it increases the reusability.
script
in body
will (likely) be allowed in HTML 5.2 (W3C’s next HTML Recommendation).
The current HTML 5.2 Working Draft for the style
element specifies:
Contexts in which this element can be used:
- Where metadata content is expected.
- In a
noscript
element that is a child of ahead
element.- In the
body
, where flow content is expected.
(This last line is not included in HTML 5.1, which is the current HTML Recommendation.)
Here’s the issue asking to update the validator used by the W3C:
style element conforming in body in w3c HTML
Check in inspect element for styles in head
var styles = "<style>"+
"@font-face { "+
"font-family: 'LilyUPC'; "+
"src: url('/common/upcll.ttf');}"+
"div.footer {"+
"position: fixed;" +
"bottom: 0;" +
"left:0;" +
"right:0;" +
"background-color: black;" +
"float:down;" +
"text-align:center;" +
"z-index: 20;"+
"font-family: 'LilyUPC';" +
"color:red;" +
"font-size:12pt;" +
"text-decoration:underline;}" +
"</style>";
$("head").append(styles);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="other">Unstyled content here</div>
<div class="footer">Styled content here</div>
then in php you put this js inside <script </script>
and echo the whole script
Like this:
echo("
<script>
var styles = \"<style>\"+
\"@font-face { \"+
\"font-family: 'LilyUPC'; \"+
\"src: url('/common/upcll.ttf');}\"+
\"div.footer {\"+
\"position: fixed;\" +
\"bottom: 0;\" +
\"left:0;\" +
\"right:0;\" +
\"background-color: black;\" +
\"float:down;\" +
\"text-align:center;\" +
\"z-index: 20;\"+
\"font-family: 'LilyUPC';\" +
\"color:red;\" +
\"font-size:12pt;\" +
\"text-decoration:underline;}\" +
\"</style>\";
$(\"head\").append(styles);
</script>
");