jiuwo
jiuwo

Reputation: 86

is there a way to center align this span element without affecting how the element renders?

I'm rendering rating stars using this and I need to center all the elements of my html page, including the stars. The page will look like this:

enter image description here

Problem is, when I use <center> or <style="text-align: center;"> the stars end up looking like this:

code:

<center>
  <span class="stars">4</span>
</center>

result:

4/5 star rating

Is there a way to center the span class without affecting how it renders? I tried using margin-left/right but they look pretty bad when I change the size of the browser/use it on a phone.

What it is:

enter image description here

What I want:

enter image description here

Upvotes: 0

Views: 83

Answers (2)

Shadow Fiend
Shadow Fiend

Reputation: 1829

use margin: 0 auto;. It will center to its parent div..

If you want to understand more about margin: 0 auto; try this link.

Upvotes: 1

Aldorath
Aldorath

Reputation: 45

It's hard to answer without more information about context and what you're trying to do, but have you tried using CSS rather than HTML tags?

.stars { text-align: center }

Upvotes: 0

Related Questions