使用 HTML 和无 CSS 居中图像链接 [英] Centering an image link with HTML and no CSS

查看:42
本文介绍了使用 HTML 和无 CSS 居中图像链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图仅使用 HTML 而不使用 CSS 将图像居中,这可能吗?我尝试了以下代码:

<img src="URL" align="center"></a>

但是图像不会移动.我该如何解决这个问题?

我试图居中的图像是我正在放置的博客右栏中的捐赠按钮文本"小部件中的链接,因此 CSS 似乎在那里不起作用.

解决方案

好吧,您可以使用

,但它不再受支持.最好的办法是在 HTML 和 text-align:center 中使用 style 属性.这不会直接使图像居中,因此您可以将其包装在带有样式的 div 中:

<a href="链接"><img src="URL" align="center"></a>

在查看发布的评论后,我发现您实际上不需要 div.只需将其应用到它周围的链接即可.

<img src="URL" align="center"></a>

没有 CSS 就没有办法做到这一点,除非你想使用过时的东西.

I am trying to center an image using only HTML and no CSS, is this possible? I have tried the following code:

<a href="link">
<img src="URL" align="center"></a>

However the image doesn't move. How can I solve this?

The image I am trying to center is the donate button on the right column of our blog I am placing the link in a "text" widget so the CSS doesn't seem to work there.

解决方案

Well, you could use <center>, but it is no longer supported. Your best bet here is to use the style attribute in HTML and text-align:center. This won't directly center the image, so you would wrap it in a div with the styling:

<div style="text-align: center">
<a href="link">

<img src="URL" align="center"></a>
</div>

After looking at a comment that was posted, I see that you actually don't need the div. Just apply it to the link around it.

<a href="link" style="text-align: center">

<img src="URL" align="center"></a>

There is no possible way to do this without CSS, unless you want to use outdated stuff.

这篇关于使用 HTML 和无 CSS 居中图像链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆