1D0-61B · Question #25
When a developer wants to center a paragraph of text, which code should she use?
The correct answer is C. <p style="text-align: center"> This is the text to center</p>. Option C is correct because inline CSS styles in HTML are applied using the style attribute with a value formatted as property: value - so style="text-align: center" is the proper syntax. A is wrong because text-align is a CSS property, not an HTML attribute - you can't write…
Question
When a developer wants to center a paragraph of text, which code should she use?
Options
- A<p text-align="center">This is the text to center</p>
- B<p"text-align: center"> This is the text to center</p>
- C<p style="text-align: center"> This is the text to center</p>
- D<p style: text-align="center"> This is the text to center</p>
How the community answered
(15 responses)- C93% (14)
- D7% (1)
Explanation
Option C is correct because inline CSS styles in HTML are applied using the style attribute with a value formatted as property: value - so style="text-align: center" is the proper syntax.
- A is wrong because
text-alignis a CSS property, not an HTML attribute - you can't write it directly inside the tag without thestyleattribute. - B is wrong because the
styleattribute is missing entirely; the quote mark appears beforetext-align, making it invalid HTML. - D is wrong because it reverses the syntax -
style:is not how HTML attributes work; the colon belongs inside the quotes as part of the CSS declaration, not outside.
Memory tip: Think of it as two layers - the HTML attribute (style=) acts as a "container," and inside the quotes you write normal CSS (property: value). If either layer breaks its own syntax rules, the whole thing fails.
Topics
Community Discussion
No community discussion yet for this question.