Div align Example : DIV Style « HTML « JavaScript DHTML






Div align Example

    
<html>
<head>
<script language="JavaScript">
    function function1() {
        document.all.myDiv.align = "center";
    }
    function function2() {
        document.all.myDiv.align = "justify";
    }
    function function3() {
        document.all.myDiv.align = "left";
    }
    function function4() {
        document.all.myDiv.align = "right";
    }
</script>
</head>
<body>
<div id="myDiv" 
     style="position:absolute; 
            visibility:visible; 
            width:354px; 
            height:122px; 
            background-color:red; 
            border:1px none #000000">
    <span>Span Span Span Span Span Span Span Span Span Span Span Span</span>
</div>
<input type="Button" value="Center" onClick="function1();">
<input type="Button" value="Justify" onClick="function2();">
<input type="Button" value="Left" onClick="function3();">
<input type="Button" value="Right" onClick="function4();">
</body>
</html>

    
      
      








Related examples in the same category

1.Using the content Editable Property
2.Using clientHeight and clientWidth Properties