除标题

等之外的 HTML 元素

发布于 2024-08-15 16:43:54 字数 225 浏览 4 评论 0原文

我正在浏览我的问题的相关问题,但似乎找不到答案。无论如何,我想知道当我已经在我的网站上将两者(p 和 div 标签)用作纯文本时,我是否仍然可以使用 p 或 div 标签而不是标题标签。原因是我只想在我的网站中出现一个标头标签 h1。我试图调整一些部分,但一路上迷失了方向。遗憾的是,经过几次测试后,它不起作用...我想知道这是否可能,或者除了 header 标签之外是否还有其他 HTML 标签可以使用。非常感谢你们的任何回复。 =)

I was browsing related issues for my question but I can't seem to find the answer for it. Anyways, I want to know if I can still use the p or div tags instead of header tags when I have already used both (p and div tags) as plain text on my site. The reason is that I only want to have one header tag h1 present in my site. I tried to tweak some parts and got lost along the way. Sadly, after a couple of testing, it did not work... I was wondering if it's possible or if there's any other HTML tag that I can use other than header tag. Any response from you guys will be very much appreciated. =)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

一片旧的回忆 2024-08-22 16:43:55

您可以反复使用 PDIV 标记。如果需要,请将它们设置为类似于 H1 的样式。

p.title {
  font-size:18px;
  font-weight:bold;
}
p.header2 {
  background: url("bg.jpg");
}

--

<p class="title">My Title</p>
<p>And this paragraph will simply be regular text.</p>

<p class="title header2">My Other Title, with a Background Image</p>
<p>And this paragraph will also be regular text.</p>

You can use P and DIV tags over and over. If you need to, style them to look like H1's.

p.title {
  font-size:18px;
  font-weight:bold;
}
p.header2 {
  background: url("bg.jpg");
}

--

<p class="title">My Title</p>
<p>And this paragraph will simply be regular text.</p>

<p class="title header2">My Other Title, with a Background Image</p>
<p>And this paragraph will also be regular text.</p>
究竟谁懂我的在乎 2024-08-22 16:43:55

不要忘记记住您网站上的搜索引擎优化。想必这就是为什么你只想要一个 H1 标签的原因?

Don't forget to remember SEO on your site. Presumably this is why you only want one H1 tag?

镜花水月 2024-08-22 16:43:55

是您可以在

标签。

<span> <strong> and <em> are others you can use inside your <p> tags.

紫轩蝶泪 2024-08-22 16:43:55

我会使用

标签并使用 ids 或类来控制样式。如果只有一次实例或类,并且您想重复此样式,请使用 ids。您还可以在一个元素上使用多个类,

例如

<div id="text">Text Here</div>

<span class="red">This would be red</span>

<div class="red big">This would be big and red</div>

使用 css

#text{ font-size: 20px; }
.red{ color: red; }
.big{ font-size: 40px; }

希望这会有所帮助

i would use <div> or <span> tags and use ids or classes to control the style. use ids if there is only once instance or classes if you want to repeat this style. you can also use multiple classes on one element

for example

<div id="text">Text Here</div>

<span class="red">This would be red</span>

<div class="red big">This would be big and red</div>

with css

#text{ font-size: 20px; }
.red{ color: red; }
.big{ font-size: 40px; }

hope this helps

撩发小公举 2024-08-22 16:43:55

您可以使用多个 h1 或 h2,然后像这样定位它们:

<div id="header"><h1>Title of page/h1></div>
<div id="main"><h1>Title of article</h1></div>

#header h1{ color:red;}
#main h1{ color:blue;}

这并不完全是您所要求的。我怀疑谷歌比单一的 H1 方法更聪明。

You can use multiple h1's or h2's and just target them like this:

<div id="header"><h1>Title of page/h1></div>
<div id="main"><h1>Title of article</h1></div>

#header h1{ color:red;}
#main h1{ color:blue;}

It's not quite what you're asking. I suspect Google is a bit smarter than single H1 approaches.

待"谢繁草 2024-08-22 16:43:54

您可以将

设为您喜欢的外观,例如:

<p class="header">This is a header</p>

使用

p.header { font-size: 200%; font-weight: bold; }

,但我建议反对它。原因是 HTML(表面上)是语义的,因此如果您声明:

<h3>This is a header</h3>

您实际上是在(语义上)说给定的文本某种标题。请记住,您有

,您可以选择使用其中的哪一个。不需要使用

来使用

等等。

这对于视觉障碍者也很有用,因为对于那些使用屏幕阅读器的人来说,标题样式的内容不会被指示,但标题会被指示。您应该尽可能解决可访问性问题。

You can make a <p> look however you like, for example:

<p class="header">This is a header</p>

with

p.header { font-size: 200%; font-weight: bold; }

but I would recommend against it. The reason is that HTML is (ostensibly) semantic so if you declare:

<h3>This is a header</h3>

you're actually saying (semantically) that the given text is a heading of some sort. Remember you have <h1> through <h6> and you can pick and choose which of them you use. There is no need to use <h1> to use <h2> and so on.

This is also useful for those visually impaired as something styled as a heading won't be indicated as such to those using screen readers but a heading will be. You should cater for accessibility issues where possible.

那支青花 2024-08-22 16:43:54

您不应该将 div、span 或 p 设置为看起来像标题,然后将其用于 h1-h6 之外的位置。这完全违背了经验法则背后的精神,即一页上不应该有多个 h1。

You should not style a div, span, or p to look like a heading and then use it in place off an h1-h6. That is exactly contrary to the spirit behind the rule of thumb that you shouldn't have more than one h1 on a page.

英雄似剑 2024-08-22 16:43:54

也是一个有用的补充。

<span> is a useful addition, as well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文