如何在html和css中将链接与中心对齐?
我想将页面中的三个链接(锚定标签)居中对齐 我尝试在css文件中执行此操作:如何在html和css中将链接与中心对齐?,html,css,hyperlink,alignment,Html,Css,Hyperlink,Alignment,我想将页面中的三个链接(锚定标签)居中对齐 我尝试在css文件中执行此操作: a { text-align: center; } 但是它不起作用,我也没有发现应该如何做 这是我的html: <!DOCTYPE html> <html lang="en"> <head> <link href="styles.css" rel="stylesheet"&g
a {
text-align: center;
}
但是它不起作用,我也没有发现应该如何做
这是我的html:
<!DOCTYPE html>
<html lang="en">
<head>
<link href="styles.css" rel="stylesheet">
<title>homepage</title>
</head>
<body>
<h1 id="head_heading">This is a webpage about Thunder_Coder</h1>
<p>You may have not known, but Thunder_Coder is mostly interested in two things: music and programming. <br>You may follow any of the links on the bottom to see more about Thunder_Coder, and about Thunder_Coders interests</p>
<a class="text-center" href="music.html">Music</a>
<a class="text-center" href="programming.html">Programming</a>
<a class="text-center" href="about.html">About Thunder_coder</a>
</body>
</html>
主页
这是一个关于Thunder_编码器的网页
您可能不知道,但Thunder_Coder主要对两件事感兴趣:音乐和编程
您可以按照底部的任何链接查看更多有关Thunder\u Coder和Thunder\u Coder兴趣的信息
我们无法更改
您需要将“文本对齐:居中”添加到锚定标记所在的任何父标记中
如果在div中有锚定标记,则将其添加到div中,而不是锚定标记
例如:
css:
html:
你能附上你正在尝试的html/css代码片段吗?请解释你想要达到的目的。@can:我想将我页面中的三个链接(锚定标记)居中对齐。看起来你是堆栈溢出的新手,欢迎!请与我们分享您的HTML结构,为什么?这可能是因为你的锚定标签被其他html标签包裹,但我们不知道这一点,这很重要,为什么?因为层次结构在HTML中很重要。这也取决于你想要达到的目标,这将使我们更好地理解整体概念和背景。
<p> <a> </a> </p>
<p style="text-align:center;"><a></a></p>
<p style="text-align:center;"><a href="https://example.com">my text</a></p>
div{
text-align: center;
}
<body>
<div>
<a href="#">this is a link</a>
</div>
</body>