1D0-610 · Question #95
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 it uses valid inline CSS syntax: the style attribute accepts a CSS property-value pair written as "property: value", making style="text-align: center" the proper way to apply styling directly to an HTML element. A is wrong because text-align is a CSS…
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
(46 responses)- A4% (2)
- B2% (1)
- C87% (40)
- D7% (3)
Explanation
Option C is correct because it uses valid inline CSS syntax: the style attribute accepts a CSS property-value pair written as "property: value", making style="text-align: center" the proper way to apply styling directly to an HTML element.
- A is wrong because
text-alignis a CSS property, not an HTML attribute - you cannot write it directly on the tag without thestyleattribute. - B is wrong because it omits the
style=attribute name, so the browser has no way to interpret the quoted CSS string. - D is wrong because it inverts the syntax -
style:with an equals sign is neither valid HTML attribute syntax nor valid CSS; the colon belongs inside the quotes after the property name, not outside.
Memory tip: Think of the style attribute like a mini CSS rule in quotes - style="property: value" - the colon always lives inside the quotes between the CSS property and its value, just like in a regular stylesheet.
Topics
Community Discussion
No community discussion yet for this question.