Question:

What is wrong with this html coding?

by  |  earlier

0 LIKES UnLike

<b><u><font color="#FF9900"><font size="7"><style> body {font-family = century gothic} </style> Hi and welcome to my site</font></font></u></b>

I want it to be bold underlined orange size 7 and in century gothic font and how do i correct it?

Sorry i am just learning html as i am bored in the hols.

 Tags:

   Report

5 ANSWERS


  1. David is right.  Your total approach is very 1990s.  We do it very differently now.  The best way to do this now is with CSS.  You do it by putting only very minimal code in the HTML, like this:

    &lt;style id = &quot;greeting&quot;&gt;

    Hi and welcome to my site

    &lt;/style&gt;

    You then put all the instructions for how the code should look in your heading, in a special area called a style sheet. It would look something like this:

    &lt;style type = &quot;text/css&quot;&gt;

    .greeting {

      font-weight: bold;

      text-decoration: underlined;

      font-color: #FF9900;

      font-size: 1em;

      font-family: &quot;century gothic&quot;, fantasy;

    }

    &lt;/style&gt;

    This separates the display commands from the content of the site. CSS is also much more flexible and powerful than the older HTML commands.  

    Here&#039;s a few more thoughts on the style:

    o You should really avoid underlining, because users will think the text is a link.

    o Font size 7 is the default size, which is not very useful.  In CSS font size is best measured in percentages of standard size or in ems (the width of a capital M of the current font)

    o There&#039;s no way to guarantee that a particular font will display because it may not be present on the user&#039;s computer. Be sure to include at least one default font.

    See examples from my book at

    http://www.aharrisbooks.net/xfd


  2. You should add some quotes in the century gothic, so it should be &quot;century gothic&quot;

    They should be like this :

    &lt;b&gt;&lt;u&gt;&lt;font color=&quot;#FF9900&quot;&gt;&lt;font size=&quot;7&quot;&gt;&lt;style&gt; body {font-family = &quot;century gothic&quot;} &lt;/style&gt; Hi and welcome to my site&lt;/font&gt;&lt;/font&gt;&lt;/u&gt;&lt;/b&gt;

    Without quotes, Century Gothic will be treated as century.

    Hope this help.

    HSP

  3. The b element is presentational and should not be used. Use CSS instead.

    The u element is presentational, makes things that are not links look like links, and should not be used. Don&#039;t underline things that are not links.

    The font element is presentational, deprecated and should not be used. Use CSS instead.

    The style element is forbidden inside font elements, it may only appear as a child element of the head element.

    The type attribute is not optional for style elements

    CSS property / value pairs are linked with colons, not equals signs.

    Font names containing white space (such as a regular space) should be surrounded with quote marks.

  4. David is absolutely correct and here&#039;s what he means:

    1. Don&#039;t use &lt;b&gt;. Rather, use  font-wieght: bold;  inside your &lt;style&gt; element.

    2. Refrane from underlining things unless they&#039;re a hyperlink, so don&#039;t use &lt;u&gt; here.

    3. &lt;font&gt; is dead. It should no longer be used as part of any web page.

    4. &lt;style&gt; has to go between the &lt;head&gt; element and should not appear anywhere else in a web page.

    Example: &lt;head&gt;&lt;style type=&quot;text/css&quot;&gt;&#039;your CSS goes here&#039;&lt;/style&gt;&lt;/head&gt;

    5. &lt;style&gt; has a required attribute called &quot;type&quot; and the value here should be &quot;text/css&quot;, so your &lt;style&gt; tag should look like:

    &lt;style type=&quot;text/css&quot;&gt;&#039;your CSS goes here&#039;&lt;/style&gt;

    6. CSS properties/values are what go inside your &lt;style&gt; element. You seperate the two with a colon. They should look like:

    &lt;style type=&quot;text/css&quot;&gt;

    font-family: &quot;Century Gothic&quot;;

    &lt;/style&gt;

    (Notice the use of the colon instead of an equal sign between the CSS property font-family and it&#039;s value &quot;Century Gothic&quot; ).

    7. If you&#039;re using a font name that contains spaces such as Century Gothic, you must surround it with quotation marks.

    Example: font-family: &quot;Century Gothic&quot;;

    By the way, CSS stands for Cascading Style Sheets. CSS is used to style your HTML document. That is, the presentation of your document, how your document looks.

    ----------------------------

    The markup you posted above is invalid. I&#039;ve pasted, below, the valid HTML you&#039;re looking for. Copy, paste and save this as an HTML file and then take a look. You should validate your web pages before posting them online. You can do this at http://validator.w3.org.

    You may be wondering why the invalid markup still works as you expect it to when you view your web page. Well, that&#039;s because web browsers are terribly friendly and they try to guess at what you&#039;re trying to do when they come across invalid markup. Sometimes they get it right and your page looks fine and sometimes they don&#039;t and your page looks a total mess!

    Take a look at http://www.w3schools.com. It&#039;s an excellent resource for learning *valid* HTML/XHTML, CSS, and tons more.

    Hope this helps!

    ----------------------------

    &lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-...

    &lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;

    &lt;head&gt;

    &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;

    &lt;title&gt;HTML Help&lt;/title&gt;

    &lt;style type=&quot;text/css&quot;&gt;

    body {

    font-family: &quot;Century Gothic&quot;;

    font-size: 7pt;

    font-weight: bold;

    color: #FF9900;

    }

    &lt;/style&gt;

    &lt;/head&gt;

    &lt;body&gt;

    Hi and welcome to my site

    &lt;/body&gt;

    &lt;/html&gt;

  5. Download SeaMonkey for free and use Composer, the Website building tool - (Window &gt; Composer or Pencil icon at bottom).

    As well as the HTML view, it has a WYSIWYG tool too (what you see is what you get) so you can see instantly the font you want. It is as easy to use as Word.

Question Stats

Latest activity: earlier.
This question has 5 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.