1.

Some Examples Of Good And Bad Coding. What Is Wrong With This?

Answer»

<FONT size="3"&GT;Welcome to my page</font>

Comment: The font-tag is design and design shouldn’t be in the HTML document. All design should be in the CSS-file! Instead do this:

In the HTML:

<h1>Welcome to my page</h1>

In the CSS:

h1 { font-size: 2em; }

One more example:

<b>An error occurred</b>

This looks right doesn’t it? But if you look up what <b> stands for you quickly FIND bold. But bold is CERTAINLY design, so it still doesn’t belong in the HTML document. A better choice is <em> that stands for emphasis or simply “this piece of text is important”. So instead of saying “this text looks like this” you are saying “this text is important” and you let the looks be decided by the CSS. Seems like a minor change, but it illustrates how to select your tags. Use this instead:

In the HTML:

<em>An error occured</em>

In the CSS:

em {
font-weight: bold;
color: RED;
}
One last example:
<table>
<tr><td><a href="">first link</a></td></tr>
<tr><td><a href="">second link</a></td></tr>
...
</table>

<font size="3">Welcome to my page</font>

Comment: The font-tag is design and design shouldn’t be in the HTML document. All design should be in the CSS-file! Instead do this:

In the HTML:

<h1>Welcome to my page</h1>

In the CSS:

h1 { font-size: 2em; }

One more example:

<b>An error occurred</b>

This looks right doesn’t it? But if you look up what <b> stands for you quickly find bold. But bold is certainly design, so it still doesn’t belong in the HTML document. A better choice is <em> that stands for emphasis or simply “this piece of text is important”. So instead of saying “this text looks like this” you are saying “this text is important” and you let the looks be decided by the CSS. Seems like a minor change, but it illustrates how to select your tags. Use this instead:

In the HTML:

<em>An error occured</em>

In the CSS:

em {
font-weight: bold;
color: Red;
}
One last example:
<table>
<tr><td><a href="">first link</a></td></tr>
<tr><td><a href="">second link</a></td></tr>
...
</table>



Discussion

No Comment Found