Question

It appears in the latest available version of ckeditor 3 that there isn't a way to center an image. There is a bug included, but no resolution:

http://dev.ckeditor.com/ticket/8938

It looks like it hasn't changed on ckeditor 4 beta either.

I was wondering if anyone had any successfully edits of ckeditor 3 to allow centering of images?

Thanks, David

Was it helpful?

Solution

This issue is definitely NOT related to ckeditor. The align attribute for the <img> tag is deprecated as of HTML 4, and removed as of HTML 5.

From the W3C website source:

The align attribute on the img element is obsolete. Use CSS instead.

Now, even if the attribute was used in HTML but not in ckeditor - you could see it in the final output (in production, the final website).

There are some different solutions:

  • In HTML5, you can use <center><img ... /></center> or <img style="margin:0px auto;display:block" ... />

  • In any HTML version, you can use <div style="text-align: center;"><img ... /></div> (or any other tag container like <p> <span> etc.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top