<h1>,<h2>,<h3> ...标签,内嵌段落(<p>)

Ale*_*nic 20 html css seo

我正在尝试<hx>在段落中添加标签,例如:

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam pulvinar tincidunt neque, at blandit leo mattis vitae. Cras <h2>placerat</h2> justo vel risus porta cursus. Nullam eget sem nibh. Sed <h3>mattis</h3> facilisis rhoncus. Morbi sit amet nisl lectus.</p>
Run Code Online (Sandbox Code Playgroud)

但我总是在每一个之前得到换行符,甚至应用所有这些,以及以下声明的组合:

h1, h2, h3, h4, h5, h6 {
display:inline !important;
text-transform:none;
font-weight: inherit;
font-style: inherit;
font-size: 100%;
font-family: inherit;
clear:none;
color:inherit;
margin:0;
padding:0;
}
Run Code Online (Sandbox Code Playgroud)

那么我该怎样做才能使标签与文本内联不被注意?现在我得到类似的东西

Lorem ipsum dolor坐下来,精致的adipistur elit.Aliquam pulvinar tincidunt neque,at blandit leo mattis vitae.信用评级机构

placerat justo vel risus porta cursus.Nullam eget sem nibh.桑达

mattis facilisis rhoncus.Morbi坐在amet nisl lectus.

谢谢

PS:顺便说一下,我正在使用drupal的蓝图框架主题.

SLa*_*aks 28

你误用了标题标签.

您应该使用<span>带有CSS类的标签.

试了一下,发生了什么事情,当Firefox看到<h1>里面有一个无效的标签时<p>,它会自动关闭<p>标签.你可以在Firebug中清楚地看到这一点.

  • "...... SEO机构给了我们这个方向." 然后你的SEO机构配备了白痴(或傻瓜). (5认同)
  • 一些搜索引擎知道SEO和旗帜网站的"不受欢迎的路径"技术将其除名.我会坚持使用正确的语义并使用其他方法来最大化你的排名. (4认同)
  • “CSS 类”——类是 HTML 属性。CSS 可以使用它们作为标准来选择元素,但它们存在于 HTML 中。 (2认同)
  • @Alextronic立即取消与这家SEO公司的合约!他们向你出售绝对不真实的信息和建议,如果有的话,你会从这个建议中失去更多的钱.我强烈建议在SitePoint论坛上发帖,因为一些普通用户对搜索引擎优化非常了解,并会引导您朝着正确的方向前进,或者可以指向某人的方向,让他真正知道自己在做什么. (2认同)

小智 11

只需在段落的开头放置一个h2标签即可.例如. <p>The p tags are automatically breaking as soon as the html parser reaches the hx tags. if you really want to do this you must close the p tag before the hx tag. then set p and hx to display inline!</p>是para,我们希望自动打破用h1标签封装..

<p><h2></h2>The p tags are <h1>automatically breaking</h1> as soon as the html parser reaches the hx tags. if you really want to do this you must close the p tag before the hx tag. then set p and hx to display inline!</p>
Run Code Online (Sandbox Code Playgroud)

但是当p标签自动断开时,我们无法实现我们给p标签的样式.

注意:h1标签的样式应为

h1{ display:inline; !important}
Run Code Online (Sandbox Code Playgroud)


mea*_*gar 7

<p>标签只能包含内联元素.标题标记是块级元素,<p>即使您将它们设置为内联显示,也无法进入标记内部.

根据这种用法,它们在语义上是不正确的 - 段落不应该在它们内部随机浮动.考虑正确使用<em><strong>标记,或者如果它们确实不是您要描述的内容,请使用<span>具有特定类的标记.

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam
pulvinartincidunt neque, at blandit leo mattis vitae.
Cras <em>placerat</em> justo vel risus porta cursus. Nullam eget
sem nibh. Sed <strong>mattis</strong> facilisis rhoncus. Morbi sit
amet nisl lectus.</p>
Run Code Online (Sandbox Code Playgroud)