At the moment my blocks generate their title in a <h2> tag, where do I modify it so block titles are in a <I> tags?

I've looked in the page.tpl, it doesn't seem to be there.

Thanks

Comments

nevets’s picture

With css there is no need to change the tag type, you just need to add the appropriate css. In style css it is likely you already have a rule for .block h2 or .block .title or .block h2 .title in which case can add the new css to the existing rule, otherwise you can add one something like

.block h2 {
font-style: italic;
}

The .block h2 maybe slightly different depending on your theme, the part to add is font-style: italic;

styro’s picture

like how nevets suggests.

One main reason is that h2 has an actual meaning (a second level heading) in the HTML, whereas italic is just how something looks. By swapping headings for italics you are reducing the meaningfulness of your markup. eg what does something in italics actually mean? You might not think it is that important, but (for example) it does allow things like search engines to better understand the structure of your pages.

Generally you want your HTML to contain meaningful markup (ie just using HTML tags to describe the contents meaning) while leaving how things look to the stylesheets.

--
Anton
New to Drupal? | Forum posting tips | Troubleshooting FAQ

jason342’s picture

My block titles wouldn’t really help with search engines as I have labelled them all, Box One, Box Two, Box Three, etc…

It’s easier.

Ok, in that case how can I change it to <h3> tags instead of <h2> tags?

I want to physically change it through the html page and not CSS. Thanks

Cool_Goose’s picture

Just duplicate the h2 tag in the css and name it h3 and replace the h2 tad in the html where you want.
------------------------------------------------------
Be Smart, Think Free, Choose OpenSource.

drawk’s picture

- Create block.tpl.php in your theme directory

- Paste the following into the file

<div class="<?php print "block block-$block->module" ?>" id="<?php print "block-$block->module-$block->delta"; ?>">
<h2><?php print $block->subject ?></h2>
<div class="content"><?php print $block->content ?></div>
</div>

- Change h2 to i

---
www.whatwoulddrupaldo.org

jason342’s picture

Thanks very much drawk, great help!

I have one more tag to deal with. (I hate h2 tags you see)

The "Post new comment" text is also in a <h2> tag, do you know where I can find the html for that so I could change the tag for that too please?

Thanks

Toe’s picture

Why on earth do you hate <h2> tags, but apparently not <h3>? That's just silly.

You're going about this the wrong way. If you just don't like the look of <h2>, then change the look! That's why we have CSS in the first place!

You could change the look of every <h2> on your page like this:

h2 {
  font-weight: normal;   /* as opposed to bold, bolder, or lighter */
  font-style: italic;
  font-size: small;
}

If you want to change a specific <h2> tag or set of tags (like 'all <h2> tags that appear in blocks'), then use the appropriate selectors, like in the example nevets posted. And if you need help understanding selectors, just ask! :)

jason342’s picture

Thanks for that, I’ll apply it.

But how can I take out the h2 tag for "Post new comment"?

I can't find where the "Post new comment" and its h2 is, what file should I modify?

Thanks

drawk’s picture

I don't think you're really understanding what nevets and Toe are trying to explain to you.

Jason, what is your reason for wanting to remove (or change in the HTML) the h2 tag around "Post New Comment"?

When you say you don't like h2 tags, what do you mean by that?

---
www.whatwoulddrupaldo.org

jason342’s picture

Hi Drawk,

I do know what nevets and Toe mean (thanks to both), meaning taking out h2 may effect search problems, and possible changes to a site can be made via css, I understand it and have actually applied their advice to other areas of the site.

However, I would like to take out the h2 tags around “Post New Comment”. I would appreciate it if you or anyone else kindly tell me where the file is where the h2 tags around the “Post New Comment" reside.

Thanks so much.

drawk’s picture

However, I would like to take out the h2 tags around “Post New Comment”. I would appreciate it if you or anyone else kindly tell me where the file is where the h2 tags around the “Post New Comment" reside.

I guess that's where I'm confused. It seems like either:

1) You didn't like the way "Post New Comment" appeared on your page, but have been able to change the appearance to what you wanted through CSS. However, despite having gotten things looking exactly how you want them, you *still* want to remove the h2 tags. It is hard to imagine why you might want to remove them, having gotten everything looking the way you want it to look. That's why I'm confused and curious about why you want to take them out or change them. Was appearance the problem? Were you able to fix appearance? If you were ... why break it now that it is fixed?

2) You haven't been able to get the "Post New Comment" to look the way you want. In this case, the solution isn't to rip out the h2 tags, but rather modify your CSS. Which we can help you with.

So, the question that is still on the table is: *why* do you want to remove the h2 tags?

(not trying to be difficult, and always glad to help ... just can't figure out what you are trying to do here. Or why.)

---
www.whatwoulddrupaldo.org

plycurriculum’s picture

I got really excited when I found this thread because for weeks now I've also been trying to find the html to change the h2 tag.

You started giving some really useful advice about changing the css but unfortunately the thread then went quiet.

What I want to do is to make the titles of my blocks smaller so that they are the same size as the contents but formatted differently. I manged to work out that it was the h2 tag that was governing the size of the titles but whilst I know enough css to understand what's going on I don't know how to add an element that will only affect the block title. I certainly don't want to change the size of the original h2 tag because I don't know where else it's being used in the site.

Can you help me please?

Rebecca@category.greenash.net.au’s picture

Something like

.block h2 {}

will only affect h2 elements within a div of class "block."

The exact class depends on your template, but you get the drift. Firefox's Web Developer Toolbar is really handy for drilling down to find selectors.

cazam’s picture

Hi there,

I don't suppose you could help me with how to change the h2 colour for content blocks in twilight theme? Would it be something like this?

.block h2 {
	color: #ff0000;
}

But then where on the style sheet should I insert it. It seems everywhere i try it makes no difference.

I'm trying to build a website for my husband and I'm pretty new to Drupal and it's driving me a bit mad! You can see here http://24techno.net/radio how 'Radio Lineup' is a h2 for the block but I can;t for the life of me get it to change.

Thanks!!!

Carrie
CAZAM Ltd
http://www.cazam.eu

nevets’s picture

Look in style.css line 357 and you will find the rule for .sidebar .block h2. The simple approach would be to add your color: #ff0000; there.

cazam’s picture

Thanks for the tip = I tried this but still no joy. Could it be that it is because my block is on 'content' and not the sidebar? Kind thanks!!!

Carrie
CAZAM Ltd
http://www.cazam.eu

nevets’s picture

In that case adding the following to the end of style.css should work

#main-content .block h2 {
  color: #FF0000;
}

cazam’s picture

Alas still no luck - I wonder if it is anything to do with the fact that the block title which shows on the page is inputted into Drupal as Block Description... I'm going to try and find a css for 'block description'

Carrie
CAZAM Ltd
http://www.cazam.eu

cazam’s picture

div.admin-panel .description {
	color: #ff0000;
}

still no joy

Carrie
CAZAM Ltd
http://www.cazam.eu

nevets’s picture

I looked closer at your site and you base theme uses the color module and you have "colorized" the theme. Your actual style.css file is /sites/24techno.net/files/color/twilight-5beaf96c/style.css. Though you can change the file if you re-colorize the look I think the changes will be lost. Not sure of the correct solution.

cazam’s picture

Ah I see there is another css! I am going to work my way through this one - thank you, you're a champion!

Carrie
CAZAM Ltd
http://www.cazam.eu

student2’s picture

--------------
How to change block titles and the block's items to be rtl ?
thanks

thanhbkhn’s picture

Thanks for your help, but i found mini issue, it not work on my site. Fortunately, i found useful solution => Follow this link : API BLOCK.TPL.PHP

In Drupal 7, $block->content ~ $content

kamranzafar’s picture

I want to change "Post new comment" to "Leave new comment" how can do this please help me.

apt94jesse’s picture

Hello all, I know this is an old thread, but I wanted to see if I could verbalize the headache with these h2 tags.

H tags are heavily weighted for SEO purposes. Google suggests building hierarchical text trees out of relevant content using h tags, with h1 being most important and h2 next and so on and so forth.

Right now, using a stock bluemarine theme, I have two misplaced h2 tags. One is an empty block title that outputs an open and close h2 tag with nothing in it. The other is the "post new comment" link at the bottom.

When viewed from an SEO perspective, these are two no-nos that should not be there. Google views the title of my page as h1, which is correct. In this case, if the title is "Drupal", the content looks like this to Google:

-Drupal
--
-- Post New Comment

That's obviously not how the information should be displayed.

I'm using Drupal 6.10 by the way, so the other posts that claim this issue has been fixed are wrong. By my estimation, this is not a theming issue, but rather a core module issue. The block module should have the h2 moved inside the php if tag, while the comment module should not use an h2 tag to surround their labels. These are bad practices from an SEO standpoint and can easily be replicated without using h tags.

LandscapeMafia’s picture

To modify at the core level a block's heading tag, you need to get into the block.tpl.php file (either in your theme or sub-theme's template folder) and find where it specifies the formatting of the title. The fastest way I found to do this is to open the block.tpl.php file and search for <h2> and then simply replace this tag and the closing h2 tag (</h2>) with <h3> and </h3>, respectively. The template files let you change lots of stuff. just be carefull not to WSoD your site and save a copy of the file unmodified before you start.