Jump to content

Your way of coding


u214

Recommended Posts

Hi. As y'all notice, I'm new here. I am also new to the PHP coding stuff, but not to coding.

 

Well, I tried watching other scripts to see how they are 'Coded'. I think they are in a disorderly way coded, which brings me to this question:

How would you code this following piece of snippet? :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Server</title>
<meta http-equiv="Content-Language" content="en-us" />
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<link href="STFFR.css" rel="stylesheet" type="text/css" />
</head>
<body>

<div id="header">
<h1><b>Server</b></h1>
</div>

<div id="nav">
<a href="Link1">Home</a>
<a href="Link2">Forums</a>
<a href="Link3">Search Players</a>
<a href="Link4">Player Bans</a>
</div>

<div id="content">

<h2>Control Panel</h2>

<b>Message:</b>
<form action="Logged.php" method="post">

		<p><center>User Name <input type="text" name="User" size="20" /> </p></center>

			<p><center>Password    <input type="password" name="Password" size="20" /></p></center>

			<center><p> </center><input type="submit" />

		<input type="reset" /> </p>

	<p><b><center><font color="#CF1111">Please login above!</font><center></b></p>

</form>
</div>

<div id="footer">Footer Info.. <a href="Link"> Message Link</a></div>

</body>
</html>

 

As y'all can see, code looks ugly ( In my way of scripting ), I just want to know. Is that how the code should be like? If not, can you please re do it, IN YOUR way?

 

Thanks.

Link to comment
Share on other sites

Hi m8,

 

<h1><b>Server</b></h1>

is unnecessary. Adjust the font weight in an external css.

 

<div id="nav">
<a href="Link1">Home</a>
<a href="Link2">Forums</a>
<a href="Link3">Search Players</a>
<a href="Link4">Player Bans</a>
</div>

Use an unordered list for menu's here is a guide on how to make a menu.

 

<p><center>User Name <input type="text" name="User" size="20" /> </p></center>

don't use <center> you can wrap the whole form in a div and give it a property of text-align:center; in an external style sheet.

 

<p><b><center><font color="#CF1111">Please login above!</font><center></b></p>

don't use <font> just like <center> it's a bad thing. use color:#CF1111 in an external stylesheet.

 

Biggest tip: use an external stylesheet and give elements either an id or a class to target them if they need special styling.

 

the rest looks okay

Link to comment
Share on other sites

Hi all,

 

Hay dude, just keep in mind that there no bad or good looking coading style. The only thing that matters in the coding style is that the coding should be meaningful to coder self. It does not matter you code into inline style or the tabbing style, just keep in mind that, the code you have written should be easily maintain and understood by you even if see it after a while. So you have find your own unique style by experimenting the coding style as you have done in other language.

 

Hope you will find your unique style soon.

 

Link to comment
Share on other sites

Hi all,

 

Hay dude, just keep in mind that there no bad or good looking coading style. The only thing that matters in the coding style is that the coding should be meaningful to coder self. It does not matter you code into inline style or the tabbing style, just keep in mind that, the code you have written should be easily maintain and understood by you even if see it after a while. So you have find your own unique style by experimenting the coding style as you have done in other language.

 

Hope you will find your unique style soon.

 

Well i agree on the readability, But I totally disagree on the inline style. Inline style is slower, redundant and doesn't separate concerns. But do as you like. For instance a table with valign-top on the td elements. Now say you have a table with 10 columns and 50 rows. If you would do that inline style you end up declaring it 500 times instead of 1 time. And readability, I have never seen extra added inline style that made the initial mark up more readable ever.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.