THIS POST PICK UP WHERE THE HTML & CSS PAGE LEFT OF
Explanations
- Always put
on the first line. It tells the browser about the type of the document. - The
tag indicates the start and
element contains additional information about the page. In contrast to the element, this information does not appear in the main area of the browser.- Within the
, there should be an indication about the character set:. If you do not specify the character set some special characters may not get displayed correctly. You might have noticed that theelement has no closing tag. There are a few elements without closing tags, but they are the exception. - Next you'll see the
element. The title is displayed in the title bar at the top of your browser window.
element is displayed in the main area of the browser.- A
defines the main heading. Sub headings can be created with,,,, and. - Text between
andis a paragraph.
With these basic HTML elements we are well prepared to bring our website to a new level. First, let's add an image so that the home page of our portfolio looks a bit more interesting.
Inserting an Image
To insert an image we use the element. The following example will insert my picture:
The element only has one opening but no closing tag. It contains a src and an alt attribute. The src attribute specifies the URL, that is the location and file name of the image. The alt
attribute is an "alternative text", which describes the content of the
image. This text is used by search engines and if for some reason the
image can not be displayed, for example on a screen reader for the
blind.
Relative and Absolute URLs
URLs are used for the src attribute of images and also for the href
attribute of links. The URL specifies the "address" of a file (for
example another web page or an image). Depending on the location of the
file, either a relative or absolute URL must be used.
If a file is part of the same web site, then a relative URL can be used. As we have seen in the example above, this is only the name of the file.
A relative URL is always relative to the current
HTML page. If the target file is located in another folder, this must be
taken into account. If the image from the example above were in a
subfolder called images, the relative URL would be images/marco.jpg. If the file is in a parent folder you can reach it with ../. The URL for the image in this case would be ../marco.jpg.
If the file is located on another website, an absolut URL must be used. Absolute URLs contain the entire domain name and path. An example would be http://code.makery.ch/images/marco.jpg.
Examples of Relative and Absolute URLs
Portfolio with an Image
If you have not already done so, try and insert an image in your portfolio. You must copy an image to your Portfolio folder on your computer. Make sure that you specify the exact file name, including the file extension.
All of your code could now look something like this (I've added a subheading and some more text):
index.html with Finished Portfolio Code


