简体   繁体   English

我输入什么语法将我的 HTML5 文本的标题放在网页的中心

[英]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.

相关问题 如何定义当用户在 TextInput 中输入文本并在 Kivy 中按下 Enter 时会发生什么? - How do I define what happens when user enter's text in TextInput and presses enter in Kivy? 如何使用 matplotlib 使文本居中? - How can I do to center my text using matplotlib? 如何在我的网站上将WMD降价语法转换为HTML? - How do i convert WMD markdown syntax to HTML on my site? 为什么我在运行程序时输入的前两个输入会在文本文件中重复? - Why do the first two inputs I enter when I run my program repeat in the text file? 我如何从网页中抓取 HTML 代码,因为它使用的是 beautifulsoup 而不丢失文本格式? - How do I scrape the HTML code from a webpage as it is using beautifulsoup without losing text format? 在Python中,如何在html网页中搜索文本文件中的一组字符串? - In Python, how do I search an html webpage for a set of strings in text file? 如果我需要为每个员工输入唯一 ID,语法是什么? - What's syntax if i need to enter unique id for every employee? 输入文字后,如何保持wxpython窗口打开或重新打开? - How do I have my wxpython window stay open or re-open after I enter my text? 我需要什么形状的彩色 jpeg 图像阵列才能将其输入 CNN,以及如何将其重塑为所需的形状? - What shape do I need to have my array of color jpeg images in order to enter it into a CNN, and how do I reshape it to the required shape? 我需要在我的__init__.py文件中放置什么以简化此程序包的界面? - What do I need to place in my `__init__.py` files to simplify this package's interface?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM