When I add an image to a block, Drupal automatically adds p tags around it, pushing the image down. Any suggestions on how to remove these p tags as they cause the image not to be aligned correctly?

This is the code I've added to the block:

<img src="sites/default/files/bannerimages/lassa.jpg">

And you can view the problem here:

http://s357151536.onlinehome.us/lassa_fever

(The image at the top should be centered within the blue area.)

Many thanks!!!

Comments

juliangb’s picture

This is dependent on the input format that your block uses.

For the paragraph tags to not be added - you will need to use an input format that does not include the "Lines and paragraphs break automatically" setting.

akandersen’s picture

As far as I can tell Drupal only offers two input formats - Filtered and Full HTML, and both come with the "Lines and Paragraphs break automatically" setting. Am I missing something?

enzipher’s picture

You can add a new input format and call it "Raw HTML", "wysiwyg", or something similar, and leave all checkboxes unchecked under Filters. Use this format for your block and all should be ok.

Cheers,

--

hook_world() is broken.

akandersen’s picture

This problem arose after I attempted to install a custom theme I had developed by a company that specializes in converting PSD designs into Drupal themes. The images align perfectly on the development site where the input format is set to Full HTML (and no p tags appeared).

Is there's something within the CSS that could control the appearance of the p tag? I'm reluctant to start installing new input formats when it worked perfectly in Full HTML the first time around.

enzipher’s picture

Creating a new input format is really not a big thing, and having an input format that doesn't make any modifications to the input is always good to have. If I remember correctly, the Full HTML format always add a p tag, unless the settings for the format has been changed.

You can change this with CSS if you'd like. Just add this line in any of your .css files (probably style.css):

#block-block-1 p { margin: 0 }

Cheers

--

hook_world() is broken.

akandersen’s picture

Created the new input format and it works like a charm now. Thanks!

enzipher’s picture

Glad I could help. :)

--

hook_world() is broken.

kim.le’s picture

Another way is you can download and activate the display suite module. It'll then give you another option to use display suite code.