Title: Code blocks truncated text
Last modified: November 26, 2020

---

# Code blocks truncated text

 *  Resolved [Max](https://wordpress.org/support/users/max2k/)
 * (@max2k)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/code-blocks-truncated-text/)
 * Hello,
 * I am using a lot of code blocks on my posts.
    I see that on AMP pages the lines
   are truncated and part of the text is not visible.
 * Is there any way to make these blocks more visual friendly?
    Or maybe I am missing
   a setting?
 * I see an option on the page edit – “Automatically fit text to container” .If 
   I activate this, the code block becomes a mess.
 * Thank you.

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Support [Milind More](https://wordpress.org/support/users/milindmore22/)
 * (@milindmore22)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/code-blocks-truncated-text/#post-13712076)
 * Hello [@max2k](https://wordpress.org/support/users/max2k/),
 * Code blocks should work normally on the AMP, Are you using any plugin to add 
   code blocks on your site?
 * > I see that on AMP pages the lines are truncated and part of the text is not
   > visible.
 * Can you please make sure that you have CSS property `overflow:auto` for `<code
   >` or container of `<code>`
    this will enable a horizontal scrollbar for your
   code block and the user can scroll horizontally to view the rest of the code,
   Also reducing font-size might help.
 * please share the URL of the page you are facing issues with along with site health
   information using [this](https://docs.google.com/forms/d/1JTQmphDlk9YgHpDoFRbHXpkDqv8-QmzTT7MDR4AstyQ/)
   form so we can assist you better.
 *  Thread Starter [Max](https://wordpress.org/support/users/max2k/)
 * (@max2k)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/code-blocks-truncated-text/#post-13712217)
 * >>Are you using any plugin to add code blocks on your site?
    No. It’s the default
   WordPress editor.
 * >>Can you please make sure that you have CSS property..
    This should be there
   by default? I didn’t modify any CSS/JS code. It’s a test site with only AMP plugin
   active.
 * I submitted the google form so you can take a look.
    Thank you.
 *  Plugin Support [Milind More](https://wordpress.org/support/users/milindmore22/)
 * (@milindmore22)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/code-blocks-truncated-text/#post-13712496)
 * Thanks for the URL and info I see you are using reader mode with the legacy theme.
   if you are planning on using legacy theme you may want to refer to our [guide](https://amp-wp.org/documentation/playbooks/classic-templates/)
   and modify legacy theme to suit your needs.
 * Some of the CSS seems to removed while generating the AMP page.The quick fix 
   is to add custom CSS with `amp_post_template_css` hook
 * You may use the following code snippet in the custom plugin or child themes function.
   php
 *     ```
       add_action(
       	'amp_post_template_css',
       	function() {
       		// only CSS here please...
       		?>
       		pre.wp-block-code {
       			line-height:1.2;
       			overflow:auto;
       		}
       		<?php
       	}
       );
       ```
   
 *  Thread Starter [Max](https://wordpress.org/support/users/max2k/)
 * (@max2k)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/code-blocks-truncated-text/#post-13712621)
 * Great! Thank you for the details and the code Milind.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Code blocks truncated text’ is closed to new replies.

 * ![](https://ps.w.org/amp/assets/icon.svg?rev=2527602)
 * [AMP](https://wordpress.org/plugins/amp/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/amp/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/amp/)
 * [Active Topics](https://wordpress.org/support/plugin/amp/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/amp/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/amp/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [Max](https://wordpress.org/support/users/max2k/)
 * Last activity: [5 years, 6 months ago](https://wordpress.org/support/topic/code-blocks-truncated-text/#post-13712621)
 * Status: resolved