What is a Character Set?

Computers don’t understand characters like A, B, C and so on. They only understand numbers which are represented in the binary format: 0s and 1s.

So, using a Character set, we can map a character to a numeric value.

The first character set that was…


This content originally appeared on DEV Community and was authored by Karlgusta Esimit

Computers don't understand characters like A, B, C and so on. They only understand numbers which are represented in the binary format: 0s and 1s.

So, using a Character set, we can map a character to a numeric value.

Character mapped to a numeric value

The first character set that was designed was the ASCII set, which is short for American Standard Code for Information Interchange.

ASCII can only represent the characters in the English language. So, it is very limited.

The character set that we use most these days is UTF-8, which can represent almost all characters in the world.

So, back to our code.

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE-edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>
    <body>

    </body>
</html>

Using character set UTF-8

With this meta element, <meta charset="UTF-8">, we are defining the character set used in this HTML document.

<meta name="viewport" content="width=device-width, initial-scale=1.0">

Below that, we have a meta element, <meta name="viewport content="width=device-width, initial-scale=1.0"> for configuring the viewport. The viewport is the visible area of a web page.

A blank index.html page on the browser

On a phone or a tablet, the viewport is smaller. While here on desktop, we can change the size of the view port by resizing the browser.

Resizing the browser window

So now our viewport is smaller.

Back to our code:

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE-edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>
    <body>


    </body>
</html>

HTML Boilerplate of index.html on VS Code

In this meta element, we are defining the initial width and zoom factor for the viewport. We will talk about this in more detail later. For now, all I need you to know is that we need this element so that our web page looks good on all devices: mobile, tablet, and desktop computers.

So, as a best practice, every web page should have at least these two meta elements. But we have additional meta elements. Let me show you some:

So, if you type meta:

meta:compact
meta:desc
meta:edge
meta:redirect
meta:refresh
meta:utf

All the meta displayed on VS Code

In this list we can see all types of meta elements. For example, we have an element for defining keywords on a web page. Let's select it:

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE-edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <meta name="keywords" content="HTML,CSS" />
        <title>Document</title>
    </head>
    <body></body>
</html>

The meta for keywords highlighted on VS Code

Here, we can type multiple keywords like HTML, CSS, and so on.

<meta name="keywords" content="HTML, CSS">

In the past, these keywords were heavily used for Search Engine Optimization. But these days most search engines don't put much weight on these keywords. Still, we can use them to define the keywords that represent this page.

We have another meta element for defining the description for this page.

So, if you type <meta name="description" content="">:

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE-edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <meta name="keywords" content="HTML, CSS" />
        <meta name="description" content="This is a simple HTML and CSS project." />
        <title>Document</title>
    </head>
    <body></body>
</html>

The meta for description highlighted on VS Code

In the content, we can type the description for this page. What we type here will appear on Google or other search engines when someone searches for our website.

For example, if you search for Windows here is what we get:

A search for the word apple on Google

Now, look at this text:

The meta description displayed on the browser for the Apple website

What you see here comes from this element over here:

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE-edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <meta name="keywords" content="HTML, CSS" />
        <meta name="description" content="This is a simple HTML and CSS project" />
        <title>Document</title>
    </head>
    <body></body>
</html>

The meta description highlighted on VS Code

So, this is the purpose of meta elements. With meta elements, we can get information about a web page.

Next, we are going to talk about the elements you need to know about when working with text.

See you on the next one!

P.S. 🚀 Ready to kickstart your career in web development? Join our course to master HTML, CSS, JavaScript, React, and more! Build real-world projects, learn from industry experts, and connect with a supportive community. Enroll now!


This content originally appeared on DEV Community and was authored by Karlgusta Esimit


Print Share Comment Cite Upload Translate Updates
APA

Karlgusta Esimit | Sciencx (2024-08-28T11:14:00+00:00) What is a Character Set?. Retrieved from https://www.scien.cx/2024/08/28/what-is-a-character-set/

MLA
" » What is a Character Set?." Karlgusta Esimit | Sciencx - Wednesday August 28, 2024, https://www.scien.cx/2024/08/28/what-is-a-character-set/
HARVARD
Karlgusta Esimit | Sciencx Wednesday August 28, 2024 » What is a Character Set?., viewed ,<https://www.scien.cx/2024/08/28/what-is-a-character-set/>
VANCOUVER
Karlgusta Esimit | Sciencx - » What is a Character Set?. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/08/28/what-is-a-character-set/
CHICAGO
" » What is a Character Set?." Karlgusta Esimit | Sciencx - Accessed . https://www.scien.cx/2024/08/28/what-is-a-character-set/
IEEE
" » What is a Character Set?." Karlgusta Esimit | Sciencx [Online]. Available: https://www.scien.cx/2024/08/28/what-is-a-character-set/. [Accessed: ]
rf:citation
» What is a Character Set? | Karlgusta Esimit | Sciencx | https://www.scien.cx/2024/08/28/what-is-a-character-set/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.