index.html
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Code Highlighting with Proper Line Numbers</title> <!-- Prettify.js Syntax Highlighter CDN --> <script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js?autoload=true&skin=desert&lang=php,js" defer></script> <!-- Custom CSS for showing line numbers properly --> <style> pre { padding: 10px; border: 1px solid #ccc; background-color: #f8f8f8; font-family: monospace; position: relative; } /* Custom style to force every line to have a number */ ol.linenums { margin-left: 40px !important; } ol.linenums li { list-style-type: decimal; margin-left: -55px; } </style> </head> <body> <h2>JavaScript Code Example</h2> <pre class="prettyprint linenums"> let i = 0; let j = 2; function sum(a, b) { return a + b; } </pre> <h2>PHP Code Example</h2> <pre class="prettyprint linenums"> <?php function greet($name) { echo "Hello, " . $name; } ?> </pre> </body> </html> |