Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Mar 2012
    Location
    USA
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How do I center my applet?

    Hey guys I am working on a webpage and would like my applet to be centered on the page but am not 100% sure how to do that. Here is the source.

    <html>
    <head>
    <title> My Applet </title>
    </head>
    <body bgcolor="00000" text="00ff00">
    <h1 align="center">My Applet</h1>
    <p>
    <applet code="applet.class" width=500 height=300>
    It seems your browser does not support java, or java is not enabled. Sorry!
    </applet>
    </p>
    </body>
    </html>

    Any help I can get would be much appreciated

  • #2
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,747
    Thanks
    22
    Thanked 1,838 Times in 1,822 Posts
    Hello FlexBuffChest92,
    To center an element you need three things:
    1. a valid DocType
    2. an element with a width
    3. that elements right/left margins set to auto
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • #3
    New Coder
    Join Date
    Mar 2012
    Location
    USA
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Would I use <div> then?

  • #4
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,747
    Thanks
    22
    Thanked 1,838 Times in 1,822 Posts
    "My Applet" is in heading tags that can be centered with those same rules.

    See a very simple example here -
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <style type="text/css">
    html, body {
    	margin: 0;
    	background: #fc6;
    }
    #container {
    	width: 800px;
    	margin: 30px auto;	
    	padding: 200px 0 300px;
    	background: #fff;
    	box-shadow: 0 0 20px #8493A6;
    	overflow: auto;
    }
    h1 {
    	width: 200px;
    	margin: 0 auto;
    	background: #333;
    }
    </style>
    </head>
    <body>
        <div id="container">
    		<h1>My Applet</h1>
        <!--end container--></div>
    </body>
    </html>
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •