Stigh Aarstein
Stigh Aarstein

Reputation: 73

Apply CSS to specific Span Style inside a DIV Class

Have a webpage where we can't alter the HTML but we can add custom CSS. My issue is to set the "text-align:right" to the first SPAN STYLE only. How do I do this?

<div class="pull-right" style="display: table; padding-bottom: 8px;">
	<span style="display: table-cell; padding-right: 1em; width: 90px; vertical-align: middle;">kr 115,00 x</span>
	<span style="display: table-cell; width: 75px; border: 1px solid rgb(255, 255, 255); text-align: center; vertical-align: middle;">1</span>
	<span style="display: table-cell; padding-left: 1em; width: 95px; text-align: right; vertical-align: middle;">= kr 115,00</span>
</div>

Upvotes: 1

Views: 4176

Answers (2)

Wais Kamal
Wais Kamal

Reputation: 6180

Use this CSS:

.pull-right span:first-child {
  text-align: right;
}

Upvotes: 2

Jon Uleis
Jon Uleis

Reputation: 18639

Use the CSS pseudo-class :first-child to target the first element in a container.

.pull-right span:first-child {
  text-align: right;
}

Upvotes: 2

Related Questions