nerdexam
CIW

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…

CIW Site Development Associate

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)
  • A
    4% (2)
  • B
    2% (1)
  • C
    87% (40)
  • D
    7% (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-align is a CSS property, not an HTML attribute - you cannot write it directly on the tag without the style attribute.
  • 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

#inline CSS#text-align#HTML style attribute#CSS syntax

Community Discussion

No community discussion yet for this question.

Full 1D0-610 Practice