Hello,
You can do this via JavaScript. use code something like shown below.
<!DOCTYPE html>
<html>
<head>
<title>Scroll Test</title>
<style type="text/css">
body { font: normal normal normal 16px/12px "Segoe UI", Calibri, Verdana, Tahoma, Arial; }
</style>
<script type="text/javascript">
function adjustScroll() {
var elm = document.getElementById('codeDiv');
elm.scrollLeft = (elm.scrollWidth - elm.offsetWidth)/2;
}
window.onload = adjustScroll;
</script>
</head>
<body>
<div id="codeDiv" style="width:200px; height:300px;overflow:auto;padding:0;margin:0;border:1px solid #8c8c8c;">
<pre style="margin:0;padding:0;border-width:0" id="codePart">
<span style='color:#800000; font-weight:bold; '>import</span><span style='color:#004a43; '> java</span><span style='color:#808030; '>.</span><span style='color:#004a43; '>io</span><span style='color:#808030; '>.</span><span style='color:#800000; font-weight:bold; '>*</span><span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>class</span> MyFirstProgram <span style='color:#800080; '>{</span>
<span style='color:#3f5fbf; '>/** Print a hello message */</span>
<span style='color:#800000; font-weight:bold; '>public</span> <span style='color:#800000; font-weight:bold; '>static</span> <span style='color:#bb7977; '>void</span> main<span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>String</span><span style='color:#808030; '>[</span><span style='color:#808030; '>]</span> args<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
<span style='color:#bb7977; font-weight:bold; '>BufferedReader</span> in <span style='color:#808030; '>=</span>
<span style='color:#800000; font-weight:bold; '>new</span> <span style='color:#bb7977; font-weight:bold; '>BufferedReader</span><span style='color:#808030; '>(</span><span style='color:#800000; font-weight:bold; '>new</span> <span style='color:#bb7977; font-weight:bold; '>InputStreamReader</span><span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>System</span><span style='color:#808030; '>.</span>in<span style='color:#808030; '>)</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
<span style='color:#bb7977; font-weight:bold; '>String</span> name <span style='color:#808030; '>=</span> <span style='color:#0000e6; '>"Instructor"</span><span style='color:#800080; '>;</span>
<span style='color:#bb7977; font-weight:bold; '>System</span><span style='color:#808030; '>.</span>out<span style='color:#808030; '>.</span>print<span style='color:#808030; '>(</span><span style='color:#0000e6; '>"Give your name: "</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>try</span> <span style='color:#800080; '>{</span>name <span style='color:#808030; '>=</span> in<span style='color:#808030; '>.</span>readLine<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span><span style='color:#800080; '>}</span>
<span style='color:#800000; font-weight:bold; '>catch</span><span style='color:#808030; '>(</span><span style='color:#bb7977; font-weight:bold; '>Exception</span> e<span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
<span style='color:#bb7977; font-weight:bold; '>System</span><span style='color:#808030; '>.</span>out<span style='color:#808030; '>.</span>println<span style='color:#808030; '>(</span><span style='color:#0000e6; '>"Caught an exception!"</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
<span style='color:#800080; '>}</span>
<span style='color:#bb7977; font-weight:bold; '>System</span><span style='color:#808030; '>.</span>out<span style='color:#808030; '>.</span>println<span style='color:#808030; '>(</span><span style='color:#0000e6; '>"Hello "</span> <span style='color:#808030; '>+</span> name <span style='color:#808030; '>+</span> <span style='color:#0000e6; '>"!"</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
<span style='color:#800080; '>}</span>
<span style='color:#800080; '>}</span>
</pre>
</div>
</body>
</html>
Regards,