I cant seem to find whats wrong. I have this html file used with google prettify. Both prettify.css and prettify.js are in the same directory as the html file
<html>
<head>
<script src="prettify.js"></script>
<link rel=StyleSheet href="prettify.css" type="text/css">
</head>
<body>
<pre class="prettyprint">
//Some sample text
for(int i = 0; i<10; i++){
//Do something
}
</pre>
</body>
</html>
And this is what it looks like
What am I missing to have the colors showing?
Thanks
将onload="prettyPrint()"
到文档的body标签中。
<body onload="prettyPrint()">
Here's the code that will do the proper syntax highlighting
<html>
<head>
<!--<script src="prettify.js"></script>I commented out your links-->
<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>
<!--<link rel=StyleSheet href="prettify.css" type="text/css"> I commented out your links-->
</head>
<body>
<pre class="prettyprint">
//Some sample text
for(int i = 0; i<10; i++){
//Do something
}
</pre>
</body>
</html>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.