2

I created a few regions for my footer. Inside of each region I've added a custom block with plain html code. One has the contact info, another has social media icons and the last one has a map.

The custom block dedicated for the social media icons has only an h2 heading and the a tags for the icons. I'm using font icons for the logos (I know probably not the best for accessibility), so the a tags don't have any text in between them. I am however using the title attribute along with the href attribute.

Everything gets saved and is rendered correctly, however, when I go back to the custom block to make edits all of the a tags are gone; the h2 tags are still there. As long as I don't hit the Save button again the site remains the same, but if I hit Save, obviously all of the icons are gone. I have Full HTML selected as the Text Format so I know that is not the issue. Is there a setting that I have to set to allow empty a tags or is this not allowed at all??

I don't want to hard-code these sections in my template as I want my site administrator to be able to edit each block if necessary.

Any help would be appreciated.

Thanx

I'm running Drupal 8.05 on Ubuntu 14.04

UPDATE

I double checked to make sure there aren't any missing tags. I also updated my code to:

<a href="" title="Best Rate Guarantee">
<span class="logo logo-bestrate></span>
<span class="screen-reader-text">Best Rate Guarantee</span>
</a>

This time the a tag remains but the empty span tag is removed.

  • I just checked a fresh install of 8.0.6 and I was allowed to save/render empty a tags in a block. Are you sure the markup isn't getting altered because of a un-closed tag or something like that? – Chance G Apr 18 '16 at 21:51
  • I thought that might be it too so I double and triple checked for any missing tags. I then changed my code to have the a tag wrapping an empty span tag. This time the a tag remains but the empty span tag gets removed. The span with text remains though. This is the current code: <a href="" title="Best Rate Guarantee"><span class="logo logo-bestrate></span> <span class="screen-reader-text">Best Rate Guarantee</span> </a> – chavab_1 Apr 18 '16 at 23:16
3

Just tested this on a fresh install of 8.0.6 and I think I see what is going on.

I saved a block using the Full HTML format with the following content:

<a href="#">&nbsp;</a>
<a href="#"></a>

And had it display in my sidebar region. Everything worked fine, there are two links in this block, that can only really be seen if you inspect the html.

However, when going to edit the block again, with the default as-installed text format settings, ckeditor will wrap my first link with a P tag, and completely remove the second link.

So, you have a few options.

  1. Enter an &nbsp; character inside your empty tag.
  2. Disable the ckeditor for your format and just use the plain-text editor, with the Full HTML (or a custom filter of your creation) filter.

Ckeditor is doing the fixing of your html, so getting rid of it will solve your problem.

| improve this answer | |
  • Yup, that's exactly it. So I guess it was Ckeditor doing it's thing. It's good to know. Rather than disabling the Ckeditor, I just added an &nbsp; character as you suggested. Thanx!! – chavab_1 Apr 19 '16 at 0:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.