H1 tag class (alternative)

I know that the h1 tag is important for SEO, so my whole name is H1 (bravo!)

Now I need to have a headline (like the first line of text), slightly different on some pages.

Usually I just duplicate h1 as h2 and alternate.

Question: is it possible to add a class to the title tag ... (I try without success)

+3
source share
7 answers

Of course you can:

<h1 class="someclass">…</h1>

The attribute classis in the attribute group coreattrs the main attributes that can be used with the element . h1

+11
source

You can create a title as follows:

h1 { color: red; }

Or like this:

<h1 class="fancy">Fancy</h1>

.fancy { font-family: fantasy; }

If it does not work:

  • , (ctrl-F5 )
  • , - , ( Firebug ).
  • HTML CSS

Edit:

, h1 .myClass h1.myClass - :

h1 .myClass { } /* any element with class="myClass" within an <h1> */
h1.myClass  { } /* any <h1> with class="myClass" */
+14

, h1 . , h1 , ( , ), . , , . , , , , .

. :

h1:

h1 { font-weight: bold; }

h1 h2:

h1, h2 { margin: 10px; }

h1 id="main":

#main h1 { background: #ccc; }

h2 class="Info":

h2.Info { color: #000; }

h3 class="More":

.More h3 { text-decoration: underline; }
+4

You can add a class to the tag <h1>. Like this:

<h1 class="myclass"> ... </h1>

You can easily create it like this:

<style type="text/css">
.myclass { color : green }
</style>
+2
source

title> is in your <head>, so it really doesn't make sense to add a class to it.

You can add a class to your <h1>.

<h1 class="title">
0
source

The following should work:

<html>
<head>
<style type="text/css">
h1.custom {
    color: red;
    font-size: 16px;
}
</style>
</head>
<body>

<h1 class="custom"> test </h1>
</body>
</html>
0
source

<div class='row' id='content-wrapper'>
  <div class='clear'/>
  <b:if cond='data:blog.pageType == &quot;error_page&quot;'>
  <div id='error-wrap'>
      <h1 class='error-item'>404</h1>
      <h2>Page Not Found!</h2>
      <p>Sorry, the page you were looking for in this blog does not exist.</p>
      <div class='clear'/>
    <a class='homepage' expr:href='data:blog.homepageUrl'><i class='fa fa-home'/> Go To Home</a>
  </div>
0
source

Source: https://habr.com/ru/post/1722736/


All Articles