简体   繁体   English

h1 标签中带有链接和跨度的两行

[英]Two lines with link and span in h1 tag

I have a shopify store, in the first line of my title of the product, I have an internal link to the vendor page, in the second line there is the product title.我有一个 shopify 商店,在我的产品标题的第一行,我有一个指向供应商页面的内部链接,在第二行有产品标题。
I read it's valid to put two lines with <br/> in an <h1> heading (in order not to use two h1 headings), but I want to combine it with an <a> link (1st line) and a <span> (2nd line) for different styling.我读到将带有<br/>两行放在<h1>标题中是有效的(为了不使用两个 h1 标题),但我想将它与<a>链接(第一行)和<span> (第二行)用于不同的样式。 Is it valid what I'm doing, also in terms of SEO?我正在做的事情是否有效,在 SEO 方面也是如此? Thank you for helping!!感谢您的帮助!!

<h1><a class="product-vendor-hyperlink" href="/collections/{{product.vendor | handleize}}">{{ product.vendor }}</a><br/><span class="product-single__title" itemprop="name">{{ product.title }}</span></h1>

It is valid, but not needed.它是有效的,但不是必需的。 Instead you can get rid of the br entirely.相反,您可以完全摆脱br Set one or both of your child nodes to display:block将一个或两个子节点设置为display:block

 .product-vendor-hyperlink{display:block;}
 <h1><a class="product-vendor-hyperlink" href="/collections/{{product.vendor | handleize}}">{{ product.vendor }}</a><span class="product-single__title" itemprop="name">{{ product.title }}</span></h1>

Another option is to consider the use of the <header> tag if you want to give full h1 weight to the product title but still keep the vendor link associated with being in the header.另一种选择是考虑使用<header>标签,如果您想为产品标题赋予完整的h1权重,但仍保留与标题相关联的供应商链接。 You can use this at the page level or use sections , div etc, but NOT li .您可以在页面级别使用它或使用sectionsdiv等,但不能使用li

 <header> <a class="product-vendor-hyperlink" href="/collections/{{product.vendor | handleize}}">{{ product.vendor }}</a> <h1 class="product-single__title" itemprop="name">{{ product.title }}</h1> </header>

Its valid, but its really bad in terms of SEO, use the heading hierarchy and semantic HTML5 tags instead, check the two resources below:它有效,但在 SEO 方面真的很糟糕,请改用标题层次结构和语义 HTML5 标签,检查以下两个资源:

Semantic tags 语义标签

Heading Hierarchy标题层次结构

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM