| Guide to changing the appearance of a Web page with HTML and cascading style sheets (CSS) |
![]()
|
Page Contents - Changing the AppearanceLesson Introduction - Changing the AppearanceIn this lesson you will learn how to change the appearance of your page. You will be able to:
So far the 2 web pages you have produced are displayed using the default settings of your browser. You will soon be learning methods of changing these default settings to something of your own choice. Some of the methods that have been used for a long time to produce the effect that you require are being replaced by newer methods that use Style Sheets. The older methods are said to be deprecated, these will be pointed out. Changing the settings are achieved by using elements |
|
|
AttributeThese are used in conjunction with suitable elements, extending their capabilities. They are placed within the opening tag of the element. The format used is <TAGNAME attribibuteName="value">
Step 1. Create a blank Web pageOpen Notepad or your HTML editor, and start a new file. Write the required HTML code to produce a blank Web page. As far as possible do this from memory. Refer to Required HTML Elements in Tutorial 2, if required Step 2. Save as... tut3-exercise.htm.Save as... tut3-exercise.htm to the folder my-web-pages. Step 3. View tut3-exercise.htm in your BrowserOpen your Browser and select file tut3-exercise.htm as demonstrated in Tutorial 2-View your page in a Web browser Check that you have an empty Web page. Step 4. Enter codeEnter code between the <BODY> </BODY> tags, as below. The use of copy and paste can be used if you like. <BODY>
<P>Align sample without using align</P>
<P align="center">To align sample centre must use American spelling center</P>
<P align="right">Align sample right</P>
<P align="left">Align sample left</P>
</BODY>
Step 5. Save, Refresh and Check.Save the amended file, Refresh the browser and check the display in the browser to ensure that every thing is working correctly. The result should appear as below. The border represents the edge of your browser window
If required, correct your code and repeat Step 5. Step 6. Narrow the Browser windowEnsure the browser window is not maximised, then slowly drag the right edge of the window to the left, narrowing the window.
This step demonstrates how your page can change appearance depending on the width of the Browsers window. Users with different screen resolutions will see your page differently. Carefully laid out designs can be ruined if this is not taken into consideration. |
|
|
Step 1.Start with the HTML code from the end of the previous exercise. Step 2. Elements- B EM I and STRONGEmphasise the single words 'default', 'centre', right'' and
'left' using a different element each time from the following
elements Step 3. Nesting ElementsEmphasise the single word 'American' nesting 2 elements as follows. <B><I>Word</I></B>or <I><B>Word</B></I>Do check that you have a first in, last out sequence. The start and end tags should pair up from the centre outwards. The following are wrong. Some browsers may be able to handle this error, and display as you intended. Others can be confused by tags in the wrong order. <B><I>Word</B></I> <I><B>Word</I></B> Step 4. Save, Refresh, Check the resultDepending on the browser the result displayed by the B and strong element is probably the same, also the result of I and EM are probably the same.Step 1.Start with the HTML code from the end of the previous exercise. Then add the following immediately before the end </BODY> tag <H1>Heading 1 example.</H1> <H2>Heading 2 example.</H2> <H3>Heading 3 example.</H3> <H4>Heading 4 example.</H4> <H5>Heading 5 example.</H5> <H6>Heading 6 example.</H6> Step 2. Save, Refresh, Check the resultThe display of the 6 headings will be at the headings default settings and will vary from large to small text. You will soon learn how to change the appearance of these headings using CSS, Cascading Style Sheets.
FONT Element.The FONT element is Deprecated , click on the link to read the side panel if you do not know its meaning. I learnt my HTML using the FONT element, therefore I'm am using FONT in these tutorials. Slowly I am learning more about CSS and changing over to using styles. Try to master CSS rather than relying on deprecated elements. Many sites use the FONT element, and you should be know how it is coded for backward compatibility. Fonts have the following attributes Attribute colorThe color attribute can be entered in 2 formats (Remember to use the American spelling)
Using a color name:A full list of color names is in tutorial-04a-colour-names.htm but the majority of these colours are not web colour safe. This is described in tutorial 4 Colour . In your experiments you can use the following which are the only web colour safe colour names.
Example: <FONT color="red"> Sample text </FONT> Using an hexadecimal numberUsing a hexadecimal red green blue code. Full details of this
is given in tutorial 4 Colour
<FONT color="#FF0000"> Sample text </FONT> Attribute sizeThe size attribute can be entered in 2 formats
Absolute format<FONT size="aNumber"> Sample text </FONT>
Example: <FONT size="5"> Sample largish text </FONT> Size change<FONT size="aSignaNumber">
Sample text </FONT> The + or - changes are relative to the browsers default size. The browsers default size can be changed by the deprecated BASEFONT element. BASEFONT does not alter the size of text within tables Examples: <FONT size="+4"> Sample larger text </FONT> <FONT size="-2"> Sample smaller text </FONT>
Additional FONT attributes that are available. Attribute faceIn a word processor you talk about changing a font, i.e. the name of the font being used. In HTML this is the face attribute of a font. You may have a very long list of fonts available on your computer, but the user may only have a few fonts installed. The browser can only display the fonts that are on that computer. It is best there fore to use the more popular fonts if you wish the viewer to see the font you have used. The popular fonts are: Arial Example of using the attribute face <FONT face="Arial">Text</FONT> Because of what I have said above, it is usual to give alternative choices for the face attribute, delimited by commas. Usually you end the list with one of the 2 generic font faces, serif or sans-serif. This is done as follows. <FONT face="Arial, Verdana, Helvetica, sans-serif">Text</FONT> In this example the browser will use the Arial font if installed, else it will try Verdana. Exercise 4. FONT ElementRemember that the FONT element is Deprecated so do not spend too much time on it. You can also combine attributes within an element, so try the following <FONT size="5" color="red" face="Arial, Verdana, sans-serif"> Sample largish text </FONT> Continue with the file you produced in Exercise 3, and use the font element and its attributes to alter the size and colour of some of the text in the align section. Do not use the FONT element on the heading elements. As usual Save, Refresh and check the result. When you are happy with using the Elements and attributes in this tutorial, save your file.
Improve your Web PageOpen the file page01.htm that you produced in Exercise 3 Tutorial 2. Use the Elements and attributes that have learnt about in this tutorial and improve the look of your page. Concentrate on using the heading elements to create a structure to your page. You will probably only need to use heading 1 and 2, and possibly 3. It will depend on the layout of your page. Emphasise a few words or phrases as required, with B, EM. I and strong elements. Get into the habit of saving on a regular basis. It is frustrating to lose work if your computer crashes.
|
|
|
Leisure Time - book your holiday or flights with our UK sponsorsMore Tutorials by John McGuinn
Leeds my home town Relax in the sun.
Copyright © John McGuinn 2001-03 . |