Welcome
Arachne's Web
A group focused on serving the AW community by providing help and discussion on topics such as HTML, CSS, web design, homesite decorating, netiquette and issues important to web artists.

Arachne's Web Academy (- threads, 693 posts)
    Tutorials - HTML/XHTML (317 posts)
    Social Thread

    Expand your own skills and aid others in learning HTML to XHTML by offering us a tutorial of your own! ...
    26 Members have made 107 Posts here to date.
    Google
    AncientWorlds.net Web
    Next: 11 - Colors
    Prev: 09 - Lists
    10 - Fonts
    Sankira.gif
    Author: * Sankira Qin - 15 Posts on this thread out of 1,337 Posts sitewide.
    Date: Jun 15, 2005 - 18:33

    Changing fonts

    Fonts are one of the more important elements that give a webpage its style. The default font for most browsers is Times or Times New Roman, but most operating systems come with a list of available fonts you can use for sprucing up your designs. A list of default fonts for the XP (Windows) and X (Mac) OS's can be found at X vs. XP. There are 12 fonts that are usually installed on both systems and should be safe to use. They are: arial, arial black, comic sans ms, courier, courier new, georgia, helvetica, impact, palatino, times new roman, trebuchet ms, and verdana.

    Our document appears in Times New Roman. Nice enough, but studies show that serif fonts are easier to read in hard copy (books, etc), but sans-serif fonts like Arial, Verdana, and Tahoma are easier to read onscreen. Experts on web design say you can (and for aesthetic reasons probably should) leave your headings in Times New Roman or some other decorative font, but create your body text in a sans-serif font like Arial.

    To change the font of a specific line or paragraph, you would use the tag. But this could be rather cumbersome for changing the entire body text and can be unintentionally overridden by other tags. Instead, HTML provides the element for changing the font of an entire webpage. So, for our document, that's what we'll use. Although, we'll be applying font tags to individual sections, too.

    color="number/name" size="#1-6" face="font names" linked text

    Coding Tip: Notice the sample tags says "font names." It's always better to include more than one font choice in your documents (separate the names with commas). If your initial choice isn't available on the visitor's computer, the browser will look for the second choice, then the third, and so on. If none of the choice are available, it will render the document in the computer's default font. Ending your list of options with serif (if you want a font similar to Times New Roman) or sans-serif (if you want a font similar to Arial) will cause the browser to choose something that is, at least, in the same style as the font you selected.

    Basefont - In your document, put the cursor on the line immediately below the body tag and type . That's all there is to it, but once you've created a basefont tag, you need to give it some characteristics. To change a font, HTML uses the face= attribute. So, inside your basefont tag, include face="Arial, Helvetica, sans-serif", like this:



    Warning: Notice the / at the end of this tag. Basefont is what the WC3 calls an "empty element" tag, meaning it doesn't require closing. Other examples of empty element tags are . If you recall, I mentioned that both XHTML and XML require all tags to be closed. Fortunately, XHTML provides an acceptable shorthand to close empty element tags, which is to add a forward slash (/) just before the closing bracket.

    Strictly following WC3 specifications, the tag could be written as: however, rather than seeing the element in that tag as "basefont" some older browsers will see it as "basefont/". Since this is not a valid element, they would ignore the tag. You can imagine what it would do to your design if all your line breaks and images were ignored. To get around this problem, include a space before the /. Older browsers will stop reading when they reach the space, thereby ignoring the / and rendering the tag properly. It's a rather convoluted explanation, I know. The important point is, to be standards compliant AND have your code read by both old and new browsers, be sure to end all your empty element tags with a space and a forward slash ( /).

    If you save and view your document, you'll see that the text is fairly large and ALL of it is Arial now. Something like this*:

    Tree of Life Garden

    Designing with HTML

    Arachne's Web presents a tutorial designed to help the (as yet) technologically challenged overcome HTML stage fright and begin to enjoy coding at home.


    Warning: According to W3C specifications, the basefont tag is provided to change the size of the basefont. Internet Explorer will support changing the font color or family using this tag, but Netscape does not...as you may have noticed if you're taking these tutorials using Netscape. So be aware of that when using it.


    Since Netscape doesn't change the font family using the basefont, we'll have to make that change using the tag. Ah...cross-browser compatibility can be such a pain! But we're going to have to make the same change in Internet Explorer soon, too — for a different reason. So, for now, we'll postpone worrying about it. (Trust me.)

    Font Size - To adjust our font size, we're going to add the size= attribute. In HTML, there are basically six font sizes available (1-6). These numbers indicate an increase or decrease in the default font size of your visitor's browser. The HTML default (which will match whatever font size the user has chosen) is size="3". So, by using size="2", you size the text down one step; size="4" makes it larger (and so on). To complicate things further, you can also use size="-2" or size="+1", etc... These settings indicate a percentage smaller or larger than whatever font size you have currently set in your code. That may be very confusing at first, but after playing with it a while, you'll get the hang of it. So don't worry too much about it right now...you can always experiment until you get the size you like.

    So, let's get back to our document: inside your basefont tag, either before or after the face= attribute, add size="2", so your tag will look like this:


    Now, if you save and view your document, you'll see something like this:

    Tree of Life Garden

    Designing with HTML

    Arachne's Web presents a tutorial designed to help the (as yet) technologically challenged overcome HTML stage fright and begin to enjoy coding at home.


    While we're changing font sizes, the copyright notice at the bottom of the page is something I want to include, but I don't want it to interfere with the design of my webpage. So let's make it a very small font. Since it has no font tag, we'll insert one and to make the font just slightly different than the body of the document, I'm going to use Verdana, rather than Arial. Like this:


    Now, the copyright notice should look something like this:

    Text ©2005 Hartifacts; photograph ©2001 Hartifacts; African graphics released for public use by Jaguarwoman

    Font Family - As you can see, because of the pre-formatting included in the heading tags, our last basefont change didn't affect the size of the headings font. But since we wanted our headings in Times New Roman anyway, this isn't much of a problem. We'll simply apply individual font commands to the headings to change their size and/or font family.
    • Starting with the first heading (Tree of Life Garden), put your cursor inside the heading tag (just before the word Tree) and type There's no need to include the forward slash, because this tag will require closing. The reason we put this command inside the heading tag is we dont want the heading tag to override the commands we're going to insert. The browser reads top to bottom, just as you do. If it read our font command first and THEN the heading tag, the font size command in the heading tag would take precedence over any font size we set in the font tag.


    • Next, add the face= attribute to your tag with a value of "Times New Roman, serif".


    • Remember to close your font tag, after the word Garden. (Last opened; first closed.) Like this:

    Now, if you save and look at your document, you'll see the size difference isn't so great. This is because Times New Roman is actually a smaller font than Arial. At this point, the choice of whether you change the size of the headings or not is purely up to you as a designer. I like the difference as it is, so I'm going to leave mine...after I apply the same font face= tag to the rest of my headings. But you can add a size= attribute if you wish.

    Tree of Life Garden

    Designing with HTML

    Arachne's Web presents a tutorial designed to help the (as yet) technologically challenged overcome HTML stage fright and begin to enjoy coding at home.


    *Note: you won't be able to view the source code of this document and use how some of the entries are coded as examples. You are only allowed to use one basefont tag per page. Since my examples each required a basefont tag, I had to do some CSS coding to make them look similar to the results we would see in HTML. Don't be confused by that. Or, if you are, leave a message on the discussion board and I'll try to explain it better.


    Some of the Available Attributes for Font Tags
    AttributeValueUse
    color rgb(x,x,x)
    #hexno
    name
    specifies the designer's choice of color by number or name.
    face list of font names specifies the designer's choice(s) of font
    size any number 1-7
    if basefont, numbers 1-6
    specifies predefined sizes for the font


    NEXT: 11 - Colors
    PREV: 09 - Lists
Rome - Rome, Season 1 - The Stolen Eagle


Copyright 2002-2008 AncientWorlds LLC | Code of Conduct and Terms of Service | Contact Us! | The AncientWorlds Staff