Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By rubensargsyan on
Hi,
I want to know how can I add HTML code in the block for Drupal 7. Is there any module which allow me to add HTML code in the block?
Thank you.
Comments
just change the input filter
just change the input filter to full html? It's in core no module needed
Hi, I'm too precious to answer right now. Please email me later.
Adding HTML, JS and CSS in the block field
Hi, your information is nice, i found this post while searching "Adding HTML, JS and CSS code in drupal block. just need some more details this aspect. I have made a code using HTML, JS and CSS. In normal scenario the CSS part and JS will go in "" section. But do we need to write the standard format of HTML while writing code in full HTML mode in the block? So, how can we add all there section during in the text box (full html mode)?
For example,
Now, how can write the above code that text-box(full html enabled)? Do i have to write entire code as described in the above format?
Thanks in advance.
NOTE: By error i have posted same message as comment.
You are Awesome
...
You can just add HTML code in
You can just add HTML code in your block, this is supported by Drupal by default. You might meet a html filter issue, which could be resolved by add more html elements in admin/config/content/formats
Thank you very much
aspilicious and seanray, thank you very much for your help.
Here is how to do it in more details for them who new in Drupal:
Go to Structure => Blocks => Add block, set "Text format" to "Full HTML" and write the html code into the textarea "Block body". Don't forget to fill "Block description" field, because it is required too. :)
Thank you again.
Add html code to drupal block
Please, is there a way to add html code into drupal block? I being try to create marquee text in my drupal project.. please, help
Yes. See the following
Yes. See the following comments:
* https://www.drupal.org/node/1180896#comment-4567642
* https://www.drupal.org/node/1180896#comment-4567644
* https://www.drupal.org/node/1180896#comment-4567960
Adding JS and CSS Along with HTML
Hi, your information is nice, i found this post while searching "Adding HTML, JS and CSS code in drupal block. just need some more details this aspect. I have made a code using HTML, JS and CSS. In normal scenario the CSS part and JS will go in "" section. But do we need to write the standard format of HTML while writing code in full HTML mode in the block? So, how can we add all there section during in the text box (full html mode)?
For example,
Now, how can write the above code that text-box(full html enabled)? Do i have to write entire code as described in the above format?
Blocks are a section of an
Blocks are a section of an HTML page, not the whole page. You are trying to build a whole page in the block - this cannot be done.
Adding JS and CSS in the Block along with HTML?
Dear Jaypan, Thank for the answer. I am also aware that we can not put whole page in block and it is not mentioned in my question that i am going to put whole code in block. But my question's core is since in "HTML" code we generally put JS and CSS part in the "head" section. Now I can not put that "head /head" in the block section so, what is the standard practice to put JS and CSS along with HTML? Thanks
Proper Way of adding CSS and JS
Dear Codenext,
You can add HTML in block without "head","script","style","link","body","html" and "meta". You would just need to add specific html for that block and the rest of the layout html will render from page.tpl.php, for CSS and JS you should add it in theme's css and js file.
Let me know if you have further questions.
Thanks
Uzma Abdul Rasheed
Hi, I leaned that now, at
Hi, I leaned that now, at that time I was in very initial stage in Drupal learning. Later I asked questions on drupal answer/stakexchangeand got the answers. Now I am quite comfortable with that. Thanks for providing answer though, very appreciated.
No html support
There are already many posts on the html issue.. pls tell me how can i actually insert html code in any of my pages, basic page or an article. for example i want to use hyperlink tag or strong tag, it doesnt work when i view the page...
=-=
That indicates that you aren't using the proper text format or have the tags needed set as allowed. Please review the documentation regarding text formats.
am i doing right
i hv enabled full html and im acting as adminstrator.. do i need anything else.. ?.. again when i enabe php format for the same page everything goes fine.. php and html both work... but setting full html doesnt seem to work.
=-=
edit the config of the of the text format. Have you check which tags are allowed? FULL HTML is only a concept. It doesn't magically allow ALL tags to be used. Again, please read the text format documentation.
Follow following instructions
@harismuzaffer
First let me explain about the text formats which is located at Administration->Configuration->Content Authoring->Text Format
Now, if you read the following Link, there is a some issue with the drupal text format, Normally we select the text format when we create the content type, but that selection will not reflect in your final saved content type, it will show the all the options.
Now, if you click the Administration->Configuration->Content Authoring->Text Format, you will see the following order,
- Filtered HTML
- Full HTML
- Plain Text
so, what happens, whichever is first works as default this is by default cinfiguration, so if above case everywhere default will be Filtered. Now what you do change the order, as shown below, so for you it will always be full HTML and for the visitors it will always be filtered HTML as visitors do not have access of administration, so this part is set.
- Full HTML
- Filtered HTML
- Plain Text
Hope you get it till now.
Now, other check open the Administration->Configuration->Content Authoring->Text Format->Full HTML, and you should see following setting, which is by default,
Make sure the "Limit allowed HTML tags" is not ticked.
So, if till this OK, your text format should work properly.
Now, Are you using CKeditor along with that? if no, not a issue, but if yes we need to check the config of CKEditor also, as CKEditor also chop off the HTML tags.
Now, you write your HTML code in the 'body' area if your HTML code is correct it should be shown properly on the final webpage. If not write the comment what is the issue?