Skip to content

How do you make a scroll box for HTML code? *Updated*

This post has been the most popular post at Blogging Basics 101 since I wrote it over a year ago. However, it’s also been the most confusing for my readers because it deals with HTML and how your blogging platform & web browsers read that HTML. So I’m tweaking this post and re-posting in the hopes I can clarify these issues a little more.

Sometimes a blog will have a button on its sidebar with a box of HTML code underneath, similar to this:

<a href=”https://www.bloggingbasics101.com”><img src=”https://www.bloggingbasics101.com/images/bb101_125x125.jpg”/></a>

You already know how to put the button on your sidebar and how to find and display the HTML. Now let’s put that HTML into a handy scroll box.

Below I will walk you through putting the code in your sidebar. First, though, I want to show you the code we’ll be using and explain how it works.

This is the code you’ll place in your sidebar:

<img src=”https://www.bloggingbasics101.com/images/bb101_125x125.jpg”><br/><div style=”border: 3px solid green; overflow: auto; height: 100px; width: 125px; color: black; background-color: white;”>YOUR TEXT HERE</div>

This will show up as the button and then a box below with the HTML code (as you see above).

The <div style=” “> and </div> are the opening and closing HTML tags you need to make the scroll box. Everything between the quotes in the <div style> tag tells the browser how to make the box appear on the screen. Let’s go through each of these items.

  • border:3px solid green — This tells the browser to make the box with a three pixel border in green. You can change the color by typing another color (e.g., red, orange, etc.) or you can change the line type by typing dashed or dotted.
  • height:100px — This tells the browser to make the box 100 pixels tall. You can change this variable by typing a different number (e.g., 200). You can play around with this until you like the appearance.
  • width:150px — This tells the browser to make the box 150 pixels wide. Again, you can control the width by typing in a different number.
  • color:black — This is the color of the text within the box. You can type the name of any color here (e.g., red, orange, green, etc.).
  • background-color:white — This is the color of the inside of your box. I encourage you to use black text on a white background as this is the easiest to read. However, you can change this color by simply typing another color name in place of white.

Now that you understand how the tag works, let’s look at what HTML you need to put use to make the box reflect your personalized HTML. Instead of YOUR TEXT HERE you should type your HTML code. For example, if you are going to put the HTML for putting the BB101 button on your site it would look like this:

<img src=”https://www.bloggingbasics101.com/images/bb101_125x125.jpg”><br/><div style=”border: 3px solid green; overflow: auto; height: 100px; width: 150px; color: black; background-color: white;”>&lt;a href=”https://www.bloggingbasics101.com”&gt;&lt;img src=”https://www.bloggingbasics101.com/images/bb101_125x125.jpg” /&gt;&lt;/a&gt; </div>

(Note that you don’t need the bold, I just added that for ease of seeing where your code goes. If you need more help with what code you’ll need, see this post on HTML code for buttons.)

If you’re at all familiar with HTML, you’ll notice that the code above does not have the regular < and > you usually see when inserting links and images. Your button code would normally look like this if you were typing it in your HTML compose tab:

<a href=”https://www.bloggingbasics101.com”><img src=”https://www.bloggingbasics101.com/images/bb101_125x125.jpg” /></a>

However, if you type the HTML above into the Compose tab or the Edit HTML tab, it is processed as HTML and will not show up properly for your readers (it will just show the button in the box instead of the HTML code). There is a work-around: Type &lt; HTML Code Here &gt; . The code for your button HTML will look like this:

&lt;a href=”https://www.bloggingbasics101.com”&gt;&lt;img src=”https://www.bloggingbasics101.com/images/bb101_125x125.jpg” /&gt;&lt;/a&gt;

(Note: The bold isn’t necessary, it’s just my way of showing you where I’ve inserted the &lt; and &gt;)

This works because &lt; is the HTML code for the < sign and &gt; is the HTML for the > sign. Placing &lt; in place of all < and &gt; in place of all > will allow your raw HTML to show up because it replaces the < and >. You’ll need to put &lt; and &gt; where ever there is an < or > in your code.

There are other work arounds as well. You can try wrapping your snippet of code in the following tags:
<pre> and </pre> tags OR
<textarea> and </textarea> OR
<code> and </code>

Now, let’s put that code in your sidebar!

TypePad

In order to add the code to your sidebar, you will need to make a new Notes Typelist.

  1. Go to Typelists > Create New Typelist.
  2. Choose Notes for the List Type and give it a name.
  3. Click Create New List.
  4. In the Note field type copy and paste this code:<div style=”border: 3px solid green; overflow: auto; height: 100px;
    width: 150px; color: black; background-color: white;”>YOUR TEXT
    HERE
    </div>
  5. Click Save.
  6. Click the Publish tab and choose which pages you want to put the scroll box on.
  7. Click Save Changes.
  8. To change where the scroll box appears, use the Content Order tool in your Design toolbox.

Blogger

  1. Log in to Blogger.
  2. Go to Layout > Template > Page Elements > Add a Page Element.
  3. Scroll down until you see HTML/Java Script and choose Add to Blog.
  4. Cut and paste the following code into the Content field (you can leave the Title field blank):<div style=”border: 3px solid green; overflow: auto; height: 100px;
    width: 150px; color: black; background-color: white;”>YOUR TEXT
    HERE
    </div>
  5. Click Save Changes.
  6. Preview your blog to see how it looks. Move the element around as needed (simply drag and drop with your mouse).
  7. Click Save.

35 thoughts on “How do you make a scroll box for HTML code? *Updated*”

  1. I’m having a bit of trouble. I just want the scroll box, and I read the entire thing and copied the code. The text shows up, but it isn’t in a box at all. It’s just normal text. Why???

  2. I’ve mostly got this working, but I cannot seem to get the scroll box to show up for whatever reason. The code itself shows up just fine, it’s simply not in a scrolling box.
    Any suggestions?

  3. i’m trying to do a post and use some code, it’s a tutorial. but i can’t get the code to just show up without trying to become what the code is for, if that makes sense. how do i get the code to just show up as code like you have above?

    thanks!!

  4. Jennifer, I looked at your code and it’s not the same as what I’ve instructed above. You have ” before the word border instead of an opening straight quote. You also have &#8221 after the word white instead of closing straight quotes. Then you have actual brackets (< and >) instead of the HTML for brackets. That won’t work–the browser will try to read it and insert the picture instead of the code. You *must* have your code look like this:

    <“a href=”http://www.itsbeenstitched.blogspot.com”><img src=”http://i1046.photobucket.com/albums/b469/Jen2000/Its%20Been%20Stitched/Linkbackpicture.jpg”>

  5. I have followed your instructions but still cannot make it work for me. Instead of a box showing up, some of the coding shows up then the image does. Please help! 🙁

    (Site linked)

  6. I”ve tried putting my code in – even put into Notepad first- and all i get is red “x” on the blog view page… i do get the box- but no image and no html code to show up…
    here is my code…can you help me?
    THANKS

  7. Ok, I’ve tried repeatedly, and I just can’t get it to work. All that shows up is the button with a red x in a box above it. My button picture seems to have too much html or something. When I paste that into “Your Text Here” that’s all I get. Oh well.

    1. Kay, without seeing your code, I’m betting that the issue is the smart quotes (curly quotes). My advice is to copy your code, paste it into TextEdit (Mac) or Notepad (PC). Delete the quotes and then re-type them. Save your code. Copy it back into your HTML editor and save. I hope that works for you! Nine times out of ten it’s the curly quotes that mess this up. I’ve several people swear they have the quotes fixed, but when I see it, the curly quotes are the problem! 🙂 Good luck!

      1. Hi, Melanie. Thanks for this great tutorial. It works great for me, but I have a problem when my followers grab my button. My site automatically changes quotes to smart quotes. I have written instructions to my readers to switch the smart quotes when they grab my button, but many people don’t read the instructions. I am trying to find a way to imbed a font in the button code, but that doesn’t seem to be working. Any ideas?

        Thanks!

    2. Perfection. Your directions are great! I’ve been putting off learning how to do this for a while. Thank you so much for including the workaround for CMS editors and code views.

    3. I’m trying to put my link (from photobucket),but it’s not working!!!
      I copy paste your code,then i change your bloggingbasics101.com into my site. and then the text code isn’t appear. only image button, not text. and the worst thing,,,no scroll!! could you help me..?? please..please..

    4. I’m trying my darndest to get the codes to show up correctly on my sidebar but I can’t figure out what I’m doing wrong! The button I have shows up fine but the scroll box doesn’t show any text or code inside. What am I doing wrong? Help please!

    5. Jane, If you’ve figured it out, do you mind sharing how you did it please? I’m having the same problem as the other bloggers. Thanks.

      1. Shinta,

        I’m re-writing this post and it will be live on Thursday, May 28. I’m hoping the new edits will help you and others with how to make the HTML code show up in the scroll box.

    6. I am trying to add my button and html to my home blog to advertise for my business blog (www.chic-cheeks.blogspot.com) and I’m having a little trouble. The HTML is there, but I can’t get it in a box. I have messed with the px sizes and it doesn’t seem to do anything. If you could go to my home blog and see if you can tell what I have done wrong..that would be great. Thanks so much,
      Tiffany

    7. I’m having the same problem as Heather with my wp blog, and a second image shows instead of the scroll box.

      Do you have a work-around for that?

      Thanks, Jane 🙂

    8. I’m having the same problem with the badge showing up on the scroll box – it’s because Blogger reads the html code that is supposed to go in the box as “html” – meaning that it doesn’t just take it as text. I don’t know what the extra codes are to make it read as text – anyone?

    9. Ack! I’m having the same issues as the other bloggers who commented. My button shows up in a scroll box, with no text. What am I doing wrong? Thank you. 🙂

    10. I must be missing something. I keep trying to install this code on my Typepad sidebar and it keeps showing up as a scrolling box with my button in the scroll box, not the CODE for my button. I’ve copied and pasted as well as typed in manually the code that you give us, but ACK! What am I missing?! Help! 🙂

    Comments are closed.