Learn Center Tag And Non Breaking Space In Html

Sharing is healthy !!

Hello guys!! In this post we are going to learn center tag and non breaking space in html.

Here we are going to talk about couple of important things. So the first thing that we are going to have a look at is the center tag.

The center tag is actually deprecated. I would suggest not to use center tag. Because there are other ways of doing what you would normally achieve by using center tag in html and you know people would suggest you to use CSS for serving your purposes.

But again as i said in the previous post it’s a very popular tag and you know it’s one of those tags that was used a lot with the previous versions of html and i just wanted you guys to know what it does.

So that if you see it in use somewhere and it’s still being supported by the way so you know you would definitely see it in a lot of places and you should just know what it’s used for.

example: Learn Center Tag And Non Breaking Space In Html

I have got this html file here,

<!DOCTYPE html>
<html>
<head>
<title>Center tag and non-breaking space example</title> </head>
<body>
<center>
<h2>This text is at center</h2>
</center>
<p>This is a normal text</p>
</body>
</html>

Output:

Learn Center Tag And Non Breaking Space In Html

You can see the above image how it looks in google chrome. So this is how it looks. You got a heading which is at the center of your web page and then you also have another sentence as a new paragraph in the body and then the title of the page.

Now in the html page you have the opening center tag and it’s just the word center between less than symbol greater than symbol for the opening and closing angular brackets. And between the opening center tag and closing center tag we have the h2 tags, that is, the opening h2 tag and closing h2 tag and in between these i have some text,

<h2>This text is at center</h2>

Let’s say i just wanted the text to be at center of the web page and i did not want it to be bold or have a greater font size.

Then i would have not used the heading tags. But since i wanted to use a greater font size and also bold text i use the heading tags and i also wanted it to be at the center of the page so that is why i use the center tag.

Also Read – How To Add HTML Paragraphs Tag

This is called combining tag or using combination of tags or cascading tags to create combined effects. So you have the heading effect combined with the center effect by using the two tags.

The sequence in which you close tags is the reverse of the sequence in which you open tag. So here i have opened the center tag first and the h2 tag after it so i have to close the h2 tag first and the center tag.

Another thing that i want to discuss in this post is let’s say i have a paragraph,

<p>             This is another normal text</p>

I put in some text as above. As you notice few characters of space after the opening <p> tag of the sentence. That is i want some space towards the left of the sentence.

Now if you think that okay you know that’s pretty simple. All we have to do is go the beginning of the sentence after the opening paragraph tag and having as many characters of spaces as is required. If you see on your browser you see that it appears the same way like nothing has changed.

That’s because as i said html is white space insensitive. Whenever you want to have spaces at places where html would not read the normal space characters as actual space. You have to use the non breaking space feature of html.

What you would have to do is, type in ampersand symbol and then “nbsp” which is a short form for non breaking space and then a semicolon like this,

<p>&nbsp;This is another normal text</p>

After putting semicolon there you must have noticed that notepad++ has changed the entire thing to italicized version. Let’s say you want to have 5 spaces. Copy and paste &nbsp; five times like this,

<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;This is another normal text</p>

After this when you see in the browser you can see that the above sentence is shifted by five characters of space.

conclusion:

So that’s it. I hope u have understood center tag and non breaking space in html.

Sharing is healthy !!

Leave a Reply

Your email address will not be published.