Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Occasionally, you're going to want to use a character or a symbol that's not readily available on your keyboard. What's more, you might want to use a symbol that's actually reserved for use by HTML. For example, using a left or right angle bracket in your content could cause rendering errors because they typically denote a tag. To use these special characters we're going to use a special code called a named-character entity. So to do that, I'm going to open up the special.htm file found in 03_07, and the first thing I want to do is just show you this page in the browser and show you a couple things that we might have some issues with here.
For example, using a left angle bracket like this in your code can cause rendering issues. So it's just sitting right there in my code, and that could cause rendering or parsing errors in certain browsers because it could cause the browser to think that a tag had opened up that never really got closed. That would result in a syntax error. We also noticed down here we have an ampersand and that is just being represented in the code with a normal ampersand and that could be an issue. And then later on, it says to display an ampersand, for example, you would type in ampersand.
Well, that doesn't seem right, so we're going to have to take a look in the code, what's going on there. And this can be extremely helpful in displaying copyright and trademark symbols. So, let's jump back into the code and kind of see what's going on here. The first thing we want to do is talk about the syntax. You can see, right here, on about line 13, we have named-character entity. It starts out by using an ampersand, which is again why you don't have a lot of just ampersands rolling around your content. Then it has the actual named character entity itself and then a semicolon.
So the ampersand lets the user agent know that, hey, this is a named-character entity, and then the semicolon lets it know that it's over and now let's move on to the rest of our content. So in order to use a left angle bracket like this one, for example, I would replace the actual character that I'd managed to type in here with 〈. So lang is that left angle bracket. How do I know that? I just know that, and then in a little bit I'm going to show you guys a reference that you can go to and kind of have a chart to find these different characters and symbols.
For example, you start with an ampersand and I'm actually showing the ampersand character. Well, we know that that can cause some problems, so I'm going to replace that with the named- character entity for that, and that would &. Let's save that. And then, finally, to display an ampersand, for example, you would type in &. Well, we know that that's not going to show the proper code, so in order to show the proper code, we have to do something that looks a little weird. We're going to have to replace this ampersand with the actual named-character entity for ampersand.
So this amp;. Now I know that looks kind of weird, but think about it this way: this is going to cause the ampersand to appear and then this is going to be just rendered as text. It will render out correctly on the page just like this. It's also helpful when you need to display things like copyright symbols and trademark symbols, so let's go ahead and replace that text with the actual symbols, so people can see what we're talking about. I'm going to highlight the text copyright and I'm just going to replace that with ©. And for trademark I'm going to go ahead and type in ™ So, and after a while, you can sort of make a logical guess as to what these symbols are if you already don't know. So if I save this and preview this in my browser, so now I'm getting my copyright symbols.
I'm getting the trademark symbols. I'm seeing an ampersand being placed in based upon named character, and again right here we're actually seeing the named-character entity being represented properly as well. And there is our left angle bracket. So where can you go to learn a little bit more about these and find a chart with all these on them? Well, I've given you a link right here to a large page on Wikipedia and if you click on that, it will take you the Wikipedia, and here is a big chart with the name and the character.
Now, the thing you have to remember, based on the way Wikipedia has this set up, is that you have to put an ampersand prior to this and then a semicolon behind it. And here are all these different named-character entities, and you can see there are a ton of them. To be honest with you, this isn't even all of them. This page includes links to further resources where you can dig into character sets even deeper. That's not to say that there aren't problems with these. There are still some issues in certain browsers. For example, if I go ahead and preview this page in Google Chrome, you'll notice that I see this sort of empty square, and that's simply a bug in Chrome.
It has a problem with the left and right angle brackets and it sort of displays those. There are different ways around that. In addition to the named-character entities there are numbers that you can type in as well. So as you're researching these special characters, make sure that you test them across browsers to see what works and what doesn't work. Have an alternate in place in case something doesn't work. So be sure to dig a little deeper into these special characters as you begin to research using them within your own HTML.
Get unlimited access to all courses for just $25/month.Become a member
58 Video lessons · 61159 Viewers
61 Video lessons · 93433 Viewers
82 Video lessons · 104355 Viewers
56 Video lessons · 107766 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.