문제

In the footer of my page http://www.imbued.co.uk/ I am getting errors on the W3C compliance test, understandably, as I've used the align attribute inline to vertically align the social media icons with its corresponding text. What is the correct CSS alternative to use? If I remove the align attribute the text and image aren't both in the centre and there is no centred float obviously.

도움이 되었습니까?

해결책

There's a few options. The best probably is to set the style on those elements to use margin: auto;

margin-left: 50%;
margin-right: 50%;
margin: auto;

In the case of one of your images, for example, it would look something like this:

<img style='margin-left: 50%; margin-right: 50%; margin: auto;' src=... />

Of course, you should just put the css in a class and set the class of anything you want centered to that class. The css class would look like:

.centered {
    margin-left: 50%;
    margin-right: 50%;
    margin: auto;
}

다른 팁

align translates best to css text-align

so

<div align="left">text</div>

becomes

<div class="left">text</div>

and in css:

.left {
text-align:left;
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top