×

Html <center> Tag

The term HTML refers to Hyper Text Markup Language. The most widely used markup language for making web pages is HTML. A structure of web page is described in HTML. There are numerous unique elements in HTML. One of the HTML elements is the center tag which is the crucial for moving any paragraph from its current position to the center. It differs from padding and margin.

What is HTML Center Tag?

In HTML, the <centre> tag is used to align text in the middle of a page. HTML5 does not support this tag.

This tag has been replaced in HTML 4 and XHTML 1 by the CSS text-align property, which can be used to align both entire div element and single p element. To center blocks, you can use the CSS margin-left and margin-right attributes with the auto setting.

Syntax

<center>Write here</center> 

Example-1

<!DOCTYPE html>  
<html>  
<head>  
    <title>Center tag</title>  
 </head>  
 <body>  
    <h2>Example of center tag</h2>  
    <center>The HTML element "center" is a block-level element that centers the con-tents of its contained element horizontally, whether they are block-level or inline. Typ-ically, but not always, the container is the body> tag.
</center>  
  </body>  
</html>  

Output:

Html Center Tag

The above example shows that the paragraph is shifted to center by center tag.

Example- 2

<!DOCTYPE html>  
<html>  
<head>  
    <title>Center tag</title>  
    <style >  
        h2{  
         text-align: center;}  
    </style>  
 </head>  
 <body>  
      <h2>Example of center tag</h2>  
      <p>In HTML 4 (and XHTML 1), this tag has been deprecated in favor of the CSS text-align property, which can be used to align the entire div element or a single p>. Use margin-left and margin-right CSS attributes with the auto setting to center blocks (or set margin to 0 auto).
</p>  
  </body>  
</html>  

Output :

Html Center Tag

In this example, we used CSS text-align property in h2 tag.

Some CSS Property

  • CSS - Font Style:
    You can use this property to add some styling in your font like Times New Roman, Calibri etc.
  • CSS Font Family:
    The CSS font-family property defines a prioritized list of one or more font family names and generic family names for the selected element.
  • CSS- Font Style:
    The CSS font-size property controls the font size of any paragraph or text.
  • CSS- Font Weight:
    The CSS font-weight property determines the font's boldness or thickness.
  • CSS text-transform:
    The CSS text-transform property controls the case and capitalization of text.
    Text decoration is described by the CSS text-decoration property, which is also known as text-decoration-line, text-decoration-color, and text-decoration-style.
  • CSS Color Property: The CSS colour property describes the text content and text decorations colors.
  • CSS background-color Property: The background color of an element is set by the CSS background-color property.
  • You can add the first line of a text block indentation by CSS text-indent property.
  • CSS text-overflow: This CSS property shows overflowed content to the user.
  • CSS white-space property: The word-break location is specified by the CSS property.
  • Shadow is added to the text by the CSS text-shadow property.
  • The CSS text-align-last: This property controls how the final line of text is aligned.
  •  CSS line-height: This property describes a line's height.
  • CSS letter-spacing property: The spaces between letters and characters in a text are determined by this CSS element.
  • CSS word-spacing property: This property determines how far apart words should be.

Attributes

The global attributes are those attributes that apply to the <center> tag. The <center> tag doesn't have any particular attribute.

However, some claim that this tag also accepts event attributes.

Browser Compatibility

Chrome

Safari

Opera

Firefox

Conclusion

 Mainly the work of Centre tag is that it shifts the current position of the paragraph to the centre and attracts the user's attention. It differs from padding and margin. It is supported in many browsers like Chrome, Opera Safari etc. It is only supported by global attribute. This tag has been replaced in HTML 4 and XHTML 1 by the CSS text-align property, which can be used to align both entire div element and single p element.


Related Topics

HTML Links

It consist of anchor element which is used to create a link between a source anchor and destination anchor. The anchor tag can be embedded between text, image, video or...

2 minutes read.

HTML City tag

HTML <City> tag HTML < cite > tag specifies a citation, a reference or title to a creative work, quoted content, books, websites, a research paper, a blog post, a painting,...

3 minutes read.

HTML Elements

An HTML element is nothing but a starting tag and then some content and then the closing tag. So we can say HTML elements is everything from the starting tag...

3 minutes read.

HTML Lists

HTML List HTML lists are used to specify data sets. All lists can include one or more elements from the list. HTML lists are available in three different types: Ordered List or...

4 minutes read.

HTML Headings

The titles and subtitles of our webpages are known as HTML headings. Let’s not talk about webpages but giving heading to almost everything like normal paragraphs, articles or let it...

2 minutes read.

HTML <span> tag

The span tag in HTML is used as an inline container element to mark up a specific or special chunk of a text or a section of a page. If you...

2 minutes read.

HTML &lt;body> alink Attribute

HTML <body> alink Attribute What is HTML? The HTML or HyperText Markup Language is used to design web pages. The file extension name for HTML file is ".html". It was released in...

2 minutes read.

HTML Text Format

Introduction HTML may format text in two different ways. The HTML tags define a text property to make it appear one way or another. A text element may also be formatted...

7 minutes read.

HTML <summary> tag

When we simply want to show the primary heading or topic name of hidden detailed material to users, then we can achieved this by using the summary tag. This makes it...

2 minutes read.

What does HTML stand for?

HTML stands for Hyper Text Markup Language. We use this markup language to design a web page. Web browsers use this language to showcase text, videos, images, audio and other...

6 minutes read.

How to create a link with no underline in HTML

In HTML, an anchor tag (<a>) is a Styled Container tag, which means when a hyperlink is created using this, browsers, by default, display the link by applying some styles...

5 minutes read.

HTML Ordered List

We use <ol> tag to make an ordered list in html. An ordered list is made to make a list of items in ordered form, ordered list can be either...

3 minutes read.

Html Wbr Tag

The Line Break Opportunity element A word break opportunity is a place in text from where the browser breaks a line. This opportunity is represented by the element wbr in the...

2 minutes read.

HTML <br> tag

HTML is referred to as Hyper Text Markup Language, which is the most popular language for creating Web pages. HTML explains the construction of a Web page. It contains a...

4 minutes read.

HTML Forms

Forms are required when we want to collect data from the user. Html forms consists of different fields to take user inputs such as: input, text area, checkbox, password, radio...

4 minutes read.

How to append HTML code to a div using JavaScript?

In HTML, we have a div tag which is used to create a box where we can put a lot of other tags. So it works like a container. So,...

4 minutes read.

HTML References

BASIC HTML TAGS TAGS DESCRIPTION <!DOCTYPE> Defines Document Type <html> Defines Html document <head> Defines Header of document <title> Defines Title of document <body> Describe all the content of document <h1> to <h6> Defines Html Heading <p> Write Paragraph in this tag <br> Line break <!--...--> Comment in Html FORMATTING TAGS TAGS DESCRIPTION <abbr> Defines...

3 minutes read.

HTML <script> Tag

For embedding a client -side script, we use script tag in html tag. This <script> tag can be used for containing scripting statements. It can also point another external script file...

2 minutes read.

HTML <source> tag

For media attributes, such as <video> tag, <audio> tag, and <picture> tag, we use the <source> tag in html for adding such type of multiple media html elements in our...

4 minutes read.

How to add Google Translate Button on your Webpage?

Google translator is a multi-language translator used for translating the webpage. Google develops it. In today's digital age, it is essential because information is available worldwide in some specific language...

5 minutes read.