[英]What syntax do I enter to place the title of my HTML5 text to the center of webpage
How would I center the title of my web page.我如何将 web 页面的标题居中。 Here is my code so far written out on paper:
到目前为止,这是我写在纸上的代码:
I want to center the heading of my title "Libertarian Nation"我想将我的标题“自由主义国家”的标题居中
The code written out without image:没有图像的代码:
<!DOCTYPE html>
<html>
<head>
<title>"Libertarian Nation"</title>
</head>
<body>
A place of decentralisation
</body>
</html>
So how could I center the title of my page?那么我怎样才能使我的页面标题居中呢?
you can simply try something like this:你可以简单地尝试这样的事情:
HTML: HTML:
<h1>A Place of Decentralization</h1>
CSS: CSS:
h1 {
text-align: center;
}
This can either go in a separate file or above between <Style>
tags.这可以 go 在单独的文件中或在
<Style>
标记之间。
Although it's now depreciated (no longer being updated and may break) you can use;虽然它现在已经折旧(不再更新并且可能会损坏),但您可以使用;
<Center>
Title!
</Center>
An alternative is creating a CSS class for it.另一种方法是为其创建 CSS class。 For example:
例如:
<Style>
. center {
Text-align: center;
}
</Style>
This will create a class in CSS called center for convenience.这将在 CSS 中创建一个 class 以方便起见。 So you can now make your title like this:
所以你现在可以这样写你的标题:
<p class="center">Title!</p>
This should now create a centered title saying Title!这现在应该创建一个居中的标题,说标题!
Please note that <Title>
does not make a title on the page itself but is the name visabel on the tab.请注意,
<Title>
不会在页面本身上制作标题,而是标签上的名称 visabel。 Please a CSS class or something like <H1>
to make your titles or headings for your website.请使用 CSS class 或类似
<H1>
的内容来为您的网站制作标题或标题。
considering 'decentralisation' is the text you wish to bring to centre.考虑到“权力下放”是您希望带到中心的文本。 Keep in mind everything in html is kind of like encapsulated eg
<body>your text </body>
is encapsulated with in body tag.请记住,html 中的所有内容都类似于封装,例如
<body>your text </body>
被封装在 body 标记中。 So this relationship is called parent child relationship...an item can have as many grands parent going all the way up to body tag and have as many grand children going all the way down to end of body tag.所以这种关系被称为父子关系......一个项目可以有尽可能多的祖父母一直到body标签,并且有尽可能多的孙子一直到body标签的末尾。
so we will create a child tag.所以我们将创建一个子标签。
<body>
<p>yourtext</p>
</body>
Once we have that then we can apply styling on to it using CSS.一旦我们有了它,我们就可以使用 CSS 对其应用样式。
<p style="text-align:center;">your text</p>
we haven't we applied Css on parent or why create encapsulating tag because it would limit the scope other wise things will be applied on all the other children of the parent as well.我们还没有在父级上应用 Css 或为什么要创建封装标签,因为它会限制 scope 其他明智的事情也将应用于父级的所有其他子级。
Further links to play around with some alignment trickery玩一些 alignment 诡计的更多链接
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.