< HTML .am>
Html special characters.
This page contains a list of HTML special characters. In HTML, special characters are typically those that can't be easily typed into a keyboard or may cause display issues if typed or pasted into a web page.
If you plan to use any of the special characters on this page, you should use either the HTML entity name or the HTML entity number. This will ensure that it displays correctly in most/all browsers.
For example, if you want to display a copyright symbol "©", you should use either © or © in your code.

HTML Reserved Characters
The following special characters are reserved in HTML. That is because these are the characters that make up the HTML language. If you use one of these characters in an article, the browser will try to interpret it as HTML. Therefore, you should use the entity name or entity number when you want to output any of these reserved characters.
General HTML Symbols
Mathematical symbols, greek characters, iso 8859-1 characters.
The following table displays the ISO 8859-1 characters.
ISO 8859-1 Symbols
The following table contains ISO 8859-1 symbols that you might find useful when coding web pages.
HTML Tutorial
Html graphics, html examples, html references, html encoding (character sets).
To display an HTML page correctly, a web browser must know which character set to use.
From ASCII to UTF-8
ASCII was the first character encoding standard. ASCII defined 128 different characters that could be used on the internet: numbers (0-9), English letters (A-Z), and some special characters like ! $ + - ( ) @ < > .
ISO-8859-1 was the default character set for HTML 4. This character set supported 256 different character codes. HTML 4 also supported UTF-8.
ANSI (Windows-1252) was the original Windows character set. ANSI is identical to ISO-8859-1, except that ANSI has 32 extra characters.
The HTML5 specification encourages web developers to use the UTF-8 character set, which covers almost all of the characters and symbols in the world!
The HTML charset Attribute
To display an HTML page correctly, a web browser must know the character set used in the page.
This is specified in the <meta> tag:
Advertisement
Differences Between Character Sets
The following table displays the differences between the character sets described above:
The ASCII Character Set
ASCII uses the values from 0 to 31 (and 127) for control characters.
ASCII uses the values from 32 to 126 for letters, digits, and symbols.
ASCII does not use the values from 128 to 255.
The ANSI Character Set (Windows-1252)
ANSI is identical to ASCII for the values from 0 to 127.
ANSI has a proprietary set of characters for the values from 128 to 159.
ANSI is identical to UTF-8 for the values from 160 to 255.
The ISO-8859-1 Character Set
ISO-8859-1 is identical to ASCII for the values from 0 to 127.
ISO-8859-1 does not use the values from 128 to 159.
ISO-8859-1 is identical to UTF-8 for the values from 160 to 255.
The UTF-8 Character Set
UTF-8 is identical to ASCII for the values from 0 to 127.
UTF-8 does not use the values from 128 to 159.
UTF-8 is identical to both ANSI and 8859-1 for the values from 160 to 255.
UTF-8 continues from the value 256 with more than 10 000 different characters.
For a closer look, study our Complete HTML Character Set Reference .

COLOR PICKER

Report Error
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
Thank You For Helping Us!
Your message has been sent to W3Schools.
Top Tutorials
Top references, top examples, get certified.
How to Use Special Characters in HTML
Add special characters in your web pages
- The Role of Special Characters
Special Characters You Can’t Type
- Non-English Characters
- What Are Hexadecimal Codes?
Add the Unicode Declaration to Your Document Head
- PHP Programming
- Java Programming
- Javascript Programming
- Delphi Programming
- C & C++ Programming
- Ruby Programming
- Visual Basic
Jennifer Kyrnin is a professional web developer who assists others in learning web design, HTML, CSS, and XML.
- University of California
- University of Washington
The web pages that you visit online are built using HTML code that tells web browsers what the content of the page is and how to render it visually for viewers. The code contains instructional building blocks known as elements, which the web page viewer never sees. The code also contains normal text characters such as those in headlines and paragraphs designed for the viewer to read.
The Role of Special Characters in HTML
When you use HTML and type the text designed to be viewed, you usually don't need any special codes — you use just your computer keyboard to add the appropriate letters or characters. A problem arises when you want to type a character in the readable text that HTML uses as part of the code itself. These characters include the < and > characters that are used in the code to start and finish every HTML tag. You may also want to include characters in the text that don’t have a direct analog on the keyboard, such as © and Ñ . For characters that don't have a key on your keyboard, you enter a code.
Special characters are specific pieces of HTML code designed to display characters that are used in the HTML code or to include characters that are not found on the keyboard in the text the viewer sees. HTML renders these special characters with either numeric or character encoding so that they can be included in an HTML document , read by the browser, and displayed properly for your site's visitors to see.
There are three characters at the core of the syntax of the HTML code. You should never use them in the readable portions of your webpage without encoding them first for proper display. They are the greater-than, less-than, and ampersand symbols. In other words, you should never use the less-than symbol < in your HTML code unless it is the start of an HTML tag. If you do, the character confuses the browsers, and your pages may not render as you expect. The three characters you should never add unencoded are:
- less-than sign <
- greater-than sign >
- ampersand &
When you type these characters directly into your HTML code — unless you are using them as elements in the code — type in the encoding for them, so they appear correctly in the readable text:
- less-than sign — <
- greater-than sign — >
- ampersand — &
Each special character begins with an ampersand — even the special character for ampersand begins with this character. Special characters end with a semicolon. Between these two characters, you add whatever is appropriate for the special character you want to add. lt (for less than ) creates the less-than symbol when it appears between the ampersand and semicolon in HTML. Similarly, gt creates the greater-than symbol and amp yields an ampersand when they are positioned between an ampersand and semicolon.
Any character that can be rendered in the Latin-1 standard character set can be rendered in HTML. If it doesn't appear on your keyboard, you use the ampersand symbol with the unique code that has been assigned to the character followed by the semicolon.
For example, the "friendly code" for the copyright symbol is © and ™ is the code for the trademark symbol.
This friendly code is easy to type and easy to remember, but there are a lot of characters that don't have a friendly code that is easy to remember.
Every character that can be typed on the screen has a corresponding decimal numeric code. You can use this numeric code to display any character. For example, the decimal numeric code for the copyright symbol — © — demonstrates how numeric codes work. They still begin with an ampersand and end with a semicolon, but instead of friendly text, you use the number sign followed by a unique number code for that character.
The friendly codes are easy to remember, but the numeric codes are often more reliable. Sites that are built with databases and XML might not have all the friendly codes defined, but they support the numeric codes.
The best way to find the numeric codes for characters is in character sets you can find online. When you find the symbol you need, just copy and paste the numeric code into your HTML.
Some character sets include:
- Currency codes
- Mathematical codes
- Punctuation codes
- Pronunciation codes
- Diacritics codes

Non-English Language Characters
Special characters aren't limited to the English language. Special characters in non-English languages can be expressed in HTML including:
So What Are Hexadecimal Codes?
Hexadecimal code is an alternate format for displaying special characters in HTML code. You can use whichever method you want for your webpage. You look them up in character sets online and use them the same way you use friendly codes or numeric codes.
Add the following meta tag anywhere inside the
No matter which method you use, keep a few best practices in mind:
Always end your entity with a semicolon
Some HTML editors allow you to post HTML codes without the final semicolon, but your pages will be invalid, and many web browsers won't display the entities correctly without it.
Always begin with an ampersand
Many web editors let you get away with leaving out the "amp;" but when you display an ampersand alone in XHTML , it causes a validation error.
Test your pages in as many browsers as you can
If the character is crucial to understanding your document and you can't test it in the browser/OS combinations that your customers use, you should find another way to represent it. However, before you resort to images or something else, try one of the browser testing tools that can validate your code in multiple browsers.
- Add Images to Web Pages Using HTML
- How to Type German Characters on a Keyboard
- How to Type German Characters on Your Computer
- Brief Introduction to URL Encoding
- How to Wrap Text Around an Image
- Using the DOCTYPE Element in Quirks Mode
- What Is An HTML Tag Versus an HTML Element?
- HTML Code for Common Symbols
- Get HTML Codes for Romanian Language Characters
- How to Insert Arrow Symbols on Your Web Page
- How to Get HTML Codes for Greek Language Characters
- How to Find the Codes or URLs for Web Images
- How to Employ HTML Codes for German Language Characters
- The String Literal
By clicking “Accept All Cookies”, you agree to the storing of cookies on your device to enhance site navigation, analyze site usage, and assist in our marketing efforts.
- Skip to main content
- Skip to search
- Skip to select language
- Sign up for free
- English (US)
Getting started with HTML
- Overview: Introduction to HTML
In this article, we cover the absolute basics of HTML. To get you started, this article defines elements, attributes, and all the other important terms you may have heard. It also explains where these fit into HTML. You will learn how HTML elements are structured, how a typical HTML page is structured, and other important basic language features. Along the way, there will be an opportunity to play with HTML too!
What is HTML?
HTML (HyperText Markup Language) is a markup language that tells web browsers how to structure the web pages you visit. It can be as complicated or as simple as the web developer wants it to be. HTML consists of a series of elements , which you use to enclose, wrap, or mark up different parts of content to make it appear or act in a certain way. The enclosing tags can make content into a hyperlink to connect to another page, italicize words, and so on. For example, consider the following line of text:
If we wanted the text to stand by itself, we could specify that it is a paragraph by enclosing it in a paragraph ( <p> ) element:
Note: Tags in HTML are not case-sensitive. This means they can be written in uppercase or lowercase. For example, a <title> tag could be written as <title> , <TITLE> , <Title> , <TiTlE> , etc., and it will work. However, it is best practice to write all tags in lowercase for consistency and readability.
Anatomy of an HTML element
Let's further explore our paragraph element from the previous section:

The anatomy of our element is:
- The opening tag: This consists of the name of the element (in this example, p for paragraph), wrapped in opening and closing angle brackets. This opening tag marks where the element begins or starts to take effect. In this example, it precedes the start of the paragraph text.
- The content: This is the content of the element. In this example, it is the paragraph text.
- The closing tag: This is the same as the opening tag, except that it includes a forward slash before the element name. This marks where the element ends. Failing to include a closing tag is a common beginner error that can produce peculiar results.
The element is the opening tag, followed by content, followed by the closing tag.
Active learning: creating your first HTML element
Edit the line below in the "Editable code" area by wrapping it with the tags <em> and </em>. To open the element , put the opening tag <em> at the start of the line. To close the element , put the closing tag </em> at the end of the line. Doing this should give the line italic text formatting! See your changes update live in the Output area.
If you make a mistake, you can clear your work using the Reset button. If you get really stuck, press the Show solution button to see the answer.
Nesting elements
Elements can be placed within other elements. This is called nesting . If we wanted to state that our cat is very grumpy, we could wrap the word very in a <strong> element, which means that the word is to have strong(er) text formatting:
There is a right and wrong way to do nesting. In the example above, we opened the p element first, then opened the strong element. For proper nesting, we should close the strong element first, before closing the p .
The following is an example of the wrong way to do nesting:
The tags have to open and close in a way that they are inside or outside one another . With the kind of overlap in the example above, the browser has to guess at your intent. This kind of guessing can result in unexpected results.
Void elements
Not all elements follow the pattern of an opening tag, content, and a closing tag. Some elements consist of a single tag, which is typically used to insert/embed something in the document. Such elements are called void elements . For example, the <img> element embeds an image file onto a page:
This would output the following:
Note: In HTML, there is no requirement to add a / at the end of a void element's tag, for example: <img src="images/cat.jpg" alt="cat" /> . However, it is also a valid syntax, and you may do this when you want your HTML to be valid XML.
Elements can also have attributes. Attributes look like this:

Attributes contain extra information about the element that won't appear in the content. In this example, the class attribute is an identifying name used to target the element with style information.
An attribute should have:
- A space between it and the element name. (For an element with more than one attribute, the attributes should be separated by spaces too.)
- The attribute name, followed by an equal sign.
- An attribute value, wrapped with opening and closing quote marks.
Active learning: Adding attributes to an element
Another example of an element is <a> . This stands for anchor . An anchor can make the text it encloses into a hyperlink. Anchors can take a number of attributes, but several are as follows:
This attribute's value specifies the web address for the link. For example: href="https://www.mozilla.org/" .
The title attribute specifies extra information about the link, such as a description of the page that is being linked to. For example, title="The Mozilla homepage" . This appears as a tooltip when a cursor hovers over the element.
The target attribute specifies the browsing context used to display the link. For example, target="_blank" will display the link in a new tab. If you want to display the linked content in the current tab, just omit this attribute.
Edit the line below in the Input area to turn it into a link to your favorite website.
- Add the <a> element.
- Add the href attribute and the title attribute.
- Specify the target attribute to open the link in the new tab.
You will be able to see your changes live in the Output area. You should see a link—that when hovered over—displays the value of the title attribute and, when clicked, opens a new tab and navigates to the web address in the href attribute. Remember that you need to include a space between the element name and between each attribute.
If you make a mistake, you can always reset it using the Reset button. If you get really stuck, press the Show solution button to see the answer.
Boolean attributes
Sometimes you will see attributes written without values. This is entirely acceptable. These are called Boolean attributes. Boolean attributes can only have one value, which is generally the same as the attribute name. For example, consider the disabled attribute, which you can assign to form input elements. (You use this to disable the form input elements so the user can't make entries. The disabled elements typically have a grayed-out appearance.) For example:
As shorthand, it is acceptable to write this as follows:
For reference, the example above also includes a non-disabled form input element. The HTML from the example above produces this result:
Omitting quotes around attribute values
If you look at code for a lot of other sites, you might come across a number of strange markup styles, including attribute values without quotes. This is permitted in certain circumstances, but it can also break your markup in other circumstances. For example, if we revisit our link example from earlier, we could write a basic version with only the href attribute, like this:
However, as soon as we add the title attribute in this way, there are problems:
As written above, the browser misinterprets the markup, mistaking the title attribute for three attributes: a title attribute with the value The , and two Boolean attributes, Mozilla and homepage . Obviously, this is not intended! It will cause errors or unexpected behavior, as you can see in the live example below. Try hovering over the link to view the title text!
Always include the attribute quotes. It avoids such problems, and results in more readable code.
Single or double quotes?
In this article, you will also notice that the attributes are wrapped in double quotes. However, you might see single quotes in some HTML code. This is a matter of style. You can feel free to choose which one you prefer. Both of these lines are equivalent:
Make sure you don't mix single quotes and double quotes. This example (below) shows a kind of mixing of quotes that will go wrong:
However, if you use one type of quote, you can include the other type of quote inside your attribute values:
To use quote marks inside other quote marks of the same type (single quote or double quote), use HTML entities . For example, this will break:
Instead, you need to do this:
Anatomy of an HTML document
Individual HTML elements aren't very useful on their own. Next, let's examine how individual elements combine to form an entire HTML page:
Here we have:
- <html></html> : The <html> element. This element wraps all the content on the page. It is sometimes known as the root element.
- <head></head> : The <head> element. This element acts as a container for everything you want to include on the HTML page, that isn't the content the page will show to viewers. This includes keywords and a page description that would appear in search results, CSS to style content, character set declarations, and more. You will learn more about this in the next article of the series.
- <meta charset="utf-8"> : The <meta> element. This element represents metadata that cannot be represented by other HTML meta-related elements, like <base> , <link> , <script> , <style> or <title> . The charset attribute specifies the character encoding for your document as UTF-8, which includes most characters from the vast majority of human written languages. With this setting, the page can now handle any textual content it might contain. There is no reason not to set this, and it can help avoid some problems later.
- <title></title> : The <title> element. This sets the title of the page, which is the title that appears in the browser tab the page is loaded in. The page title is also used to describe the page when it is bookmarked.
- <body></body> : The <body> element. This contains all the content that displays on the page, including text, images, videos, games, playable audio tracks, or whatever else.
Active learning: Adding some features to an HTML document
If you want to experiment with writing some HTML on your local computer, you can:
- Copy the HTML page example listed above.
- Create a new file in your text editor.
- Paste the code into the new text file.
- Save the file as index.html .
Note: You can also find this basic HTML template on the MDN Learning Area GitHub repo .
You can now open this file in a web browser to see what the rendered code looks like. Edit the code and refresh the browser to see what the result is. Initially, the page looks like this:

- Just below the opening tag of the <body> element, add a main title for the document. This should be wrapped inside an <h1> opening tag and </h1> closing tag.
- Edit the paragraph content to include text about a topic that you find interesting.
- Make important words stand out in bold by wrapping them inside a <strong> opening tag and </strong> closing tag.
- Add a link to your paragraph, as explained earlier in the article .
- Add an image to your document. Place it below the paragraph, as explained earlier in the article . Earn bonus points if you manage to link to a different image (either locally on your computer or somewhere else on the web).
Whitespace in HTML
In the examples above, you may have noticed that a lot of whitespace is included in the code. This is optional. These two code snippets are equivalent:
No matter how much whitespace you use inside HTML element content (which can include one or more space characters, but also line breaks), the HTML parser reduces each sequence of whitespace to a single space when rendering the code. So why use so much whitespace? The answer is readability.
It can be easier to understand what is going on in your code if you have it nicely formatted. In our HTML we've got each nested element indented by two spaces more than the one it is sitting inside. It is up to you to choose the style of formatting (how many spaces for each level of indentation, for example), but you should consider formatting it.
Let's have a look at how the browser renders the two paragraphs above with and without whitespace:
Note: Accessing the innerHTML of elements from JavaScript will keep all the whitespace intact. This may return unexpected results if the whitespace is trimmed by the browser.
Entity references: Including special characters in HTML
In HTML, the characters < , > , " , ' , and & are special characters. They are parts of the HTML syntax itself. So how do you include one of these special characters in your text? For example, if you want to use an ampersand or less-than sign, and not have it interpreted as code.
You do this with character references. These are special codes that represent characters, to be used in these exact circumstances. Each character reference starts with an ampersand (&), and ends with a semicolon (;).
The character reference equivalent could be easily remembered because the text it uses can be seen as less than for '<', quotation for ' " ' and similarly for others. To find more about entity references, see List of XML and HTML character entity references (Wikipedia).
In the example below, there are two paragraphs:
In the live output below, you can see that the first paragraph has gone wrong. The browser interprets the second instance of <p> as starting a new paragraph. The second paragraph looks fine because it has angle brackets with character references.
Note: You don't need to use entity references for any other symbols, as modern browsers will handle the actual symbols just fine as long as your HTML's character encoding is set to UTF-8 .
HTML comments
HTML has a mechanism to write comments in the code. Browsers ignore comments, effectively making comments invisible to the user. The purpose of comments is to allow you to include notes in the code to explain your logic or coding. This is very useful if you return to a code base after being away for long enough that you don't completely remember it. Likewise, comments are invaluable as different people are making changes and updates.
To write an HTML comment, wrap it in the special markers <!-- and --> . For example:
As you can see below, only the first paragraph is displayed in the live output.
You made it to the end of the article! We hope you enjoyed your tour of the basics of HTML.
At this point, you should understand what HTML looks like, and how it works at a basic level. You should also be able to write a few elements and attributes. The subsequent articles of this module go further on some of the topics introduced here, as well as presenting other concepts of the language.
- As you start to learn more about HTML, consider learning the basics of CSS (Cascading Style Sheets). CSS is the language used to style web pages, such as changing fonts or colors or altering the page layout. HTML and CSS work well together, as you will soon discover.
- Applying color to HTML elements using CSS

IMAGES
VIDEO
COMMENTS
To add such symbols to an HTML page, you can use the entity name or the entity number (a decimal or a hexadecimal reference) for the symbol. Example Display the euro sign, €, with an entity name, a decimal, and a hexadecimal value: <p> I will display € </p> <p> I will display € </p> <p> I will display € </p> Will display as: I will display €
Character HTML Entity Number HTML Entity Name Description; Œ Œ Œ capital ligature ...
ASCII defined 128 different characters that could be used on the internet: numbers (0-9), English letters (A-Z), and some special characters like ! $ + - ( ) @ < > . ISO-8859-1 was the default character set for HTML 4. This character set supported 256 different character codes. HTML 4 also supported UTF-8.
Add special characters in your web pages Table of Contents The Role of Special Characters Special Characters You Can’t Type Non-English Characters What Are Hexadecimal Codes? Add the Unicode Declaration to Your Document Head Tips By Jennifer Kyrnin Updated on February 20, 2020
The anatomy of our element is: The opening tag: This consists of the name of the element (in this example, p for paragraph), wrapped in opening and closing angle brackets. This opening tag marks where the element begins or starts to take effect. In this example, it precedes the start of the paragraph text.