HTML 2
HTML Fonts
In the previous lesson, we introduced HTML and learned the basic tags. Now, we will take it a step further. However, I want to clarify something first. In the last lesson, we mentioned that HTML5 is the latest version. With HTML5, some new features were introduced, while some older tags began to be deprecated. We will learn about these under the HTML5 section. For now, let's continue with the HTML tags that were commonly used until recently.
We learned how to print text on the screen. The simplest way is:
<html>
<body>
Hello World
</body>
</html>
We can print "Hello World" on the screen. Now, let’s display it in different styles. Open Notepad and write the following:
<html>
<body>
<b>Hello World</b><br/>
<i>Hello World</i><br/>
<u>Hello World</u><br/>
<del>Hello World</del><br/>
<sub>Hello World</sub> Hello World <sup>Hello World</sup><br/>
<marquee>Hello World</marquee><br/>
</body>
</html>
Let's explain each tag:
-
<b>...</b>
: Makes text bold (e.g., Hello World) -
<i>...</i>
: Italicizes the text (e.g., Hello World) -
<u>...</u>
: Underlines the text (e.g., Hello World) -
<del>...</del>
: Strikes through the text (e.g., Hello World) -
<sub>...</sub>
: Displays the text slightly below the baseline. This is useful for mathematical formulas, etc. (e.g., Hello World) -
<sup>...</sup>
: Displays the text slightly above the baseline. This is used to show exponentiation in math (e.g., Hello World) -
<marquee>...</marquee>
: Creates scrolling text.
Now, save the file as an HTML document and open it in your browser to see the result.
The <font>
Tag
Now let’s learn about the <font>
tag. We will use this tag to change the type, color, and size of text. Let’s see some examples:
<html>
<body>
This is normal text<br/>
<font face="Tahoma">This text is in Tahoma font</font><br/>
<font size="15">The text size is set to 15</font><br/>
<font color="red">The text color is set to red</font><br/>
<font face="Arial" size="20" color="blue">This text is in Arial, size 20, and blue</font>
</body>
</html>
Explanation: The <font>
tag allows us to apply 3 different properties to the text: color, font, and size. First, you write <font>
, then specify face
, color
, or size
. Inside face="..."
, you specify the font name, such as Arial, Tahoma, or Verdana. In color="..."
, you specify the color, such as red, yellow, blue, or aqua. Finally, size="..."
specifies the text size.
Adding Images
We can add any image to our web page, either from our computer or from a web page. For this, we will use the <img src="...">
tag. Let’s see an example, and then I’ll explain it.
<html>
<body>
<img src="C:\Users\mustafa\Desktop\New Folder\cat.jpg" >
</body>
</html>
To add an image, we use the <img src="...">
tag. Just like the <br/>
tag, this tag is self-closing. I have selected a cat image for this example. I right-clicked the image, went to properties, and copied the file path. It was C:\Users\mustafa\Desktop\New Folder
. I pasted this into the src="..."
part and added the image name cat.jpg
. It became <img src="C:\Users\mustafa\Desktop\New Folder\cat.jpg">
, and it’s now ready for use.
Writing the location and name of the image, along with its extension (e.g., .jpg
, .png
, .gif
), is enough to display the image on the page. Additionally, we can adjust the image size by specifying the width and height using the width="..."
and height="..."
attributes. Let’s see an example:
<html>
<body>
<img src="C:\Users\mustafa\Desktop\New Folder\cat.jpg" height="10" width="10">
</body>
</html>
As you can see, it's simple.
If the image and the HTML file we created are in the same folder, we only need to write the image name. For example, let’s create a folder on the desktop, copy the image there, and then create a Notepad file in the same folder with our code:
<html>
<body>
<img src="cat.jpg" height="100" width="100">
</body>
</html>
The image will appear on the web page just the same. This way, we can avoid unnecessary code and keep things simpler.
If you right-click an image from any website and copy its URL, you can display the image on your web page as well:
<html>
<body>
<img src="http://img44.imageshack.us/img44/1606/irinsevimlikediresimleri.jpg">
</body>
</html>
Changing the Background
Let’s now look at two examples of changing the background. However, remember that CSS is what really adds visual richness to the page. HTML alone is not enough for styling. Still, it’s useful to know.
<html>
<body bgcolor="black">
</body>
</html>
In this first example, we added the bgcolor="..."
attribute to the <body>
tag and set it to black. When you open the page, you’ll see a black, empty web page. You can replace "black" with other color names or their hexadecimal values. For instance, #000000
represents black, #FF0000
represents red, and #0000FF
represents blue. You don’t need to memorize these values, as you can easily find them with a quick Google search.
Now, let’s set an image as the background:
<html>
<body background="cat.jpg">
</body>
</html>
The cat image will now be set as the background. The image won’t cover the entire page. It will repeat according to its original size. We will learn more about this in CSS.
Creating Links
Finally, let's talk about creating links. To create a link, we will use the following tag: <a href="url">...</a>
. We can insert text or an image inside the link. Let’s create an example.
<html>
<body>
<a href="http://www.cagataycebi.com">Click here to visit the site</a>
<a href="http://www.cagataycebi.com"><img src="cat.jpg">Click here to visit the site</a>
</body>
</html>
Adding a link is not complicated. When you view the page in the browser, you’ll see the result. Just remember, when you write the URL, it should start with http://
. However, you don’t need to use http://
for links to other pages on the same website.
We can also make the link open in a new window by adding target="_blank"
:
<html>
<body>
<a href="http://www.cagataycebi.com" target="_blank">Click here to visit the site</a>
</body>
</html>
That’s all for this lesson. In the next lesson, we’ll learn how to create lists and tables. Take care!
Yorumlar
Yorum Gönder