• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to format code within web pages

by admin

When displaying code within web pages it can be hard to read if it hasn’t been separated from the other text and images on the page. To get around this problem you can use google code-prettify JavaScript.

This allows code to be displayed like this:

google code-prettify

To implement this within your HTML you need to add the following lines of HTML:

At the start of your page:

<script src="https://web.archive.org/web/20201124004717js_/https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script><script>

Then whenever you want to display code:

<pre class="prettyprint">
#!/bin/sh
echo "Hello, World!"
</pre>

Filed Under: Linux

Some more articles you might also be interested in …

  1. quotaon command examples in Linux
  2. locale Command Examples in Linux
  3. How to Enable IPv6 In CentOS / RHEL 5
  4. CentOS / RHEL 6 : Install and Configure SNMPv3
  5. How to use Magic SysRq tool in CentOS / RHEL
  6. Issue Opening a Firewalld Port in CentOS/RHEL 8
  7. How to Re-Create the Yum Cache and/or Force a Fetch of the Package List of the Enabled Repositories
  8. How to Count lines in a file in UNIX/Linux
  9. Basic vim commands (cheat sheet)
  10. mkpasswd Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • JavaFX ComboBox: Set a value to the combo box
  • Nginx load balancing
  • nginx 504 gateway time-out
  • Images preview with ngx_http_image_filter_module

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright