MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

WEB TECHNOLOGY

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Which CSS code centers text?
A
p {align:center;}
B
p {text-align:center;}
C
p {align=center;}
D
p {center;}
Explanation: 

Detailed explanation-1: -To center text in CSS, use the text-align property and define it with the value ‘center.’ You can use this technique inside block elements, such as divs. You can also center text in HTML, which is useful if you only want to center individual elements on the page on a case-by-case basis.

Detailed explanation-2: -To set text alignment in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML <p> tag, with the CSS property text-align for the center, left and right alignment.

Detailed explanation-3: -With CSS, you can center text in a div in multiple ways. The most common way is to use the text-align property to center text horizontally. Another way is to use the line-height and vertical-align properties. The final way exclusively applies to flex items and requires the justify-content and align-items properties.

Detailed explanation-4: -Using the <center></center> tags One way to center text or put it in the middle of the page is to enclose it within <center></center> tags. Inserting this text within HTML code would yield the following result: Center this text!

There is 1 question to complete.