• Hello guys,

    I’m trying to change the h2 tags (the tag which is used to wrap a single post title, single.php file) to h1 tag.

    What I have done is edited single.php and changed :-

    <h2><a>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a></h2>

    to

    <h1 id="single_header"><a>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a></h1>

    In style.css, I changed :-

    h2 {
    	font-size: 1.6em;
    	}

    to

    h2,h1#single_header {
    	font-size: 1.6em;
    	}

    But the things does’t seem the work. The title comes pretty big and its color is white so It is not visible. I have done some experiment and I’m able to change the white color to black by modifying this in style.css but It chages it everwhere (as it is supposed to do)

    h1, h1 a, h1 a:hover, h1 a:visited, #headerimg .description {
    	text-decoration: none;
    	color: white;
    	}

    If I change the color in black to above post It changes the color but It happens everywhere and I understand It will happen.

    Can somebody help me changing ONLY the title of single post in h1 tags and leave everything else same?

    Breif direction is ok, I’ll understand them.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Can you post a url to your site?

    Because you have color: white; defined for h1, this will affect all h1 tags unless you have a colour defined in a more specific way.

    This would work:

    h2,h1#single_header {
    font-size: 1.6em;
    color: black
    }

    Or if you don’t want your h2 to be black, you’ll have to separate it out:

    h1#single_header {
    font-size: 1.6em;
    color: black
    }
    
    h2 {
    font-size: 1.6em;
    }
    Thread Starter rock1983

    (@rock1983)

    Sorry but this doesn’t work. I’ve copied and pasted this in css file

    h1#myheader {
    font-size: 1.6em;
    color: black
    }

    then went to single .php and changed

    <h2>” rel=”bookmark” title=”Permanent Link: <?php the_title(); ?>”><?php the_title(); ?></h2>

    to

    <h1 id=”myheader”>” rel=”bookmark” title=”Permanent Link: <?php the_title(); ?>”><?php the_title(); ?></h1>

    It doesn’t work. The color of font still comes out as white. Any suggestions as what am i dong wrong here?

    Probably it is the order of the style rules.
    BTW, if you want a semantically correct code – you should have only ONE h1 tag in a page!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to change h2 to h1 in single.php?’ is closed to new replies.