1

I want to make a subtitle on a page, which needs to be centered and to have no space between it and the title.

In the CKeditor window, I entered the subtitle as the first line of text and centered it. In source, CKeditor represented this as:

<p class="rtecenter">...</p>

which results in a blank line above. I tried to remove the blank line by changing the above code to:

<br><center>...</center>

or just

<center>...</center>

But CKeditor didn't like either of those. It removed the center tag and replaced the <br> with <p>. I also tried to add an instruction in CSS as either:

<p class="rtecenter" style="margin-top:0">...</p>

or as:

<p class="rtecenter"><span style="margin-top:0">...</style></p>

CKeditor also didn't like either of those and just removed the style attribute from the first one and removed the span tag from the second.

I'm not very conversant in CSS, so I'm not sure the above code is properly formed. But the problem is that CKeditor is just removing it so I don't even get a chance to troubleshoot errors in the CSS.

CKeditor seems determined to have that blank line there. How can I get it to let me adjust this spacing between paragraphs (not globally, but on an individual paragraph)?

Thank you.

1

In your example you have:

<p class="rtecenter"><span style="margin-top:0">...</style></p>

I'm assuming that should be:

<p class="rtecenter"><span style="margin-top:0">...</span></p>

In general in terms of controlling the space between paragraphs I think the best way to do that is your CSS stylesheet, not really HTML.

Drupal and CKEditor do some HTML manipulation that you may want to checkout - admin/config/content/ckeditor, then choose your profile and click edit. Under appearance you can select/deselect some plugins that you might not need.

In terms of a quick fix though I would think that this would work:

<p class="rtecenter" style="margin-top:0; text-align:center;">...</p>

But it also depends on what is in your site's stylesheet and your theme.

  • Your proposed quick fix is the same as one of the things I tried, as posted in my question, except for adding the style to also center. – NewSites May 9 '15 at 14:35
1

Seems like CK Editor is stripping out your tags.

Are you using filter html? if so, you should check on CK Editor's allowed tags in admin/config/content/formats/filtered_html and add the tags that you need.

If the above doesn't work, check the cleanup and output settings in admin/config/content/ckeditor/edit/Advanced

  • I was using "Full HTML" with all filters turned off. --- I've decided for now to stop using CKeditor or any other WYSIWYG device and just code my pages directly in HTML and CSS. Every time I save I get my page rendered (whether I want that or not) so I can check the results of what I've done. It seems that CKeditor is suited to allowing site visitors to add content to a site. But I'm not a visitor and I want total control of what I'm doing. – NewSites May 9 '15 at 14:48
0

The question does not say if you're using the CKEditor module, or if you're using the WYSIWYG module (in which you then configure the CKEditor 'library').

I always use the WYSIWYG module (to leave the options open for a customer to pick another editor if they'd want, e.g. TinyMCE). If however I select the CKEditor library (using WYSIWYG module), then I've noticed that I must use the (older) 3.6.x version of the CKEditor, since WYSIWYG module seems to not yet support the 4.x version of CKEditor. That is: if I first try the 4.x version of CKEditor, then the WYSIWYG module doesn't find/enable it.

As per the comment "Seems like CK Editor is stripping out your tags." (in another answer), it appears to me that it might be worth trying the WYSIWYG module approach, together with CKEditor 3.6.x library. Another option might be, if you use CKEditor "module", to try to use the 3.6.x version of the "library" (I don't have experience with that combination though).

Curious to hear if this helps ...

  • Since CKeditor is to be in core in Drupal 8, it seemed to be the way to go, directly, not via the WYSIWYG module. See my comment to "No Sssweat" for the solution I've decided on for now. – NewSites May 9 '15 at 14:40

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.