Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Two different styles in the same h1 tag

Tags:

html

css

Right now my header contains two p-tags with different styles:

<p style="color:#FFF; font-size:34px; margin-bottom:10px;">First half</p>
<p style="color:#FFF; font-size:88px;">Second half</p>

Is it possible to convert this into one h1-tag? Or can I have two h1 after each other? The main purpose is that it should work well with seo.

like image 658
Rasmus Avatar asked Jul 19 '15 08:07

Rasmus


People also ask

Is it OK to have 2 H1 tags?

The Truth About Multiple H1 Tags and SEO. Our conclusion is that while it's fine to stick with one H1 per page, multiple H1s can be used as long as they are not being overused to the point of spamming, and the H1s fit contextually within the structure of the page.

Can you have 2 H1 tags on a page?

It is common to have multiple H1 heading tags in different parts of your page, in your website's template, theme or other sections. Regardless of whether you use HTML5 or not, having multiple H1 elements or multiple heading tags of the same type on a page is completely fine.

How do I use multiple styles in HTML?

You can add multiple styling properties at once when using the HTML style attribute - just make sure to separate the name-value pairs with commas. Using a separate stylesheet is very convenient for styling multiple pages, as it's easier to apply changes to one document than to each page separately.


Video Answer


1 Answers

SEO-wise - each web page should contain one H1 tag. A possible solution for what I believe you're trying to achieve is adding span tags in your H1 enabling you to style each part of your H1 differently:

HTML:

<h1>
  <span class="smallerFont">First half</span>
  <span class="bigFont">Second half</span>
</h1>

CSS:

h1 {
  color: #fff;
}

.smallerFont {
  font-size: 34px;
  margin-bottom: 10px;
}

.bigFont {
  font-size: 88px;
}
like image 182
Asaf David Avatar answered Oct 09 '22 21:10

Asaf David