Showing posts with label html. Show all posts
Showing posts with label html. Show all posts

Friday, September 18, 2015

Create an HTML Gadget with links and images

Get the files

Head over to this post to get the 2 images you need for this gadget. Once you have them downloaded and saved then you are ready to continue!

What are we doing?

We are going to create a new gadget (widget) for your blog. This gadget contains the HTML (the code behind web pages) needed to show the 2 images, along with links to our websites.

Even though this will be a gadget, we are going to start out creating it in a post, where we will have more room to work, and where we will be able to upload the images.

Upload the images into a new post

Create a new post on your blog.

Click the image icon (to the right of link), and upload the two images from the other post.

Make sure you click on each to get a blue border around them.











In the Compose view of your post, you'll see the two images.

DO NOT:
  • drag the images
  • right or left align the image
  • add captions
  • In fact, don't even click on them.
If you do the above things, Blogger adds a bunch of code to make them happen - and we don't want to deal with that!!

We now switch to HTML mode - and will stay there. Click the HTML button in the above left corner.

(Going back to Compose view and changing anything will cause Blogger to insert extra HTML or modify HTML - making your code look different than that shown in this tutorial.)




Remove the extra code


In HTML view - these are tags. HTML uses tags to set the structure of your page. Tags are enclosed inside a "less than" and a "greater than".


Carefully select and delete the "a" tags, leaving only the "img" tags as shown below. The "a" tag makes a link. In this case Blogger made each image a link to a bigger version of the image, which we don't want for the gadget.


You may also see "div" tags, which you should also delete.

Delete everything except the code shown below -  yours should look just like this!:


Now you should just have the two image (img) tags as shown above.



Add links


Stay in HTML view.


The "a" tag makes links.  
Type in the "a" tags as shown here, three under the first image and three under the second. Also add in the "br" (break) tags as shown. Those are what makes the web browser go to the next line to display whatever is next. 


The actual blank lines in the code above are only to make our code more readable - they won't show up in the browser.



Set image widths and floats


Inside each image tag, after border="0", type a space and then add the parameters shown to set a width of 30% for the image, and to float it to the left. You must get all the punctuation just right, as shown.  If there is a height declared, delete it.


Go up and click on the preview button, and you'll see something like this:


Now that each image floats left, whatever is on the page after it can come up to the right of it (wrap), when there is room.

The e floating left allows the links to come up next to it like we want, but it also made the raven to come up - which we will fix next.










In HTML view, inside the br tags after the sets of 3 links, add in the style shown, like the first one shown here. Clearing makes the browser go below the floated image to place whatever comes next.










Now hit the preview button again.

The br with the added style to clear the floats made the raven appear below the e.
















Add an image margin


The links are appearing a little too close to the images, so in HTML view, and inside the quotes for the style in the image tags, add margin:6px;.


Here's how your complete style attribute for the image tag should look now - along with the width.


And here's the complete image tag:





Almost there!

Now if you Preview, it looks pretty good.
















Round the sharp corners


The e logo is very rounded, and the raven has sharp corners. Here's how you can round out the corners a bit: Add in one more thing to the code. In the image style, add border-radius:6px;.
Check it with Preview if you want.

Copy the HTML to a gadget


Your code now looks like this. If it does, select it all, and then copy it (command-c).

Save your post, but don't publish it.



Go to edit the Design of your blog.

In that menu, choose Layout.







Find your sidebar, and click Add a Gadget.





From the list of available gadgets (known on most blogging platforms as widgets), choose the HTML/JavaScript gadget.











Paste your code (command-v) into the Content window, and title the gadget.

Press the Save button.














Up at the top, click the View blog button.





Your gadget should look something like this!

Your fonts, font sizes, and colors will be different than mine, depending on the template that you are using for your blog.









Clean it up


Click the "tools" icon to edit your gadget.



It will look better to make the links line up with the tops of the images, so select the br tag between the image and the first link, and delete it. Do this for both images. Save.






Now we just need to give that heading a little room underneath. Click the edit button again.











Add a br tag as shown, above the first image only.






Testing and done!


Nice!

Test all 6 of your links to make sure they work. This blog gadget is public on the Web when we save it. It's embarrassing to hear from others that one or more of your links don't work. Test all of your links so that you will be the first to know - and then fix them!

If your sidebar is too narrow and the links don't fit well next to the images, you can try changing the width for the images - maybe down to 25% or even 20%.


Purposes of this tutorial

  • It gives you a useful gadget for keeping up with what's going on in e-Comm and ONW.
  • It hopefully gives you at least a fuzzy idea of HTML tags. You used 3 in this tutorial - the a tag to make a link, the img tag for an image, and the br tag to advance to the next line or insert a blank line. We didn't cover the "how" or "why" behind each tag, so don't worry if it seemed complicated or mysterious to you. When we make tags ourselves later on, they will be simpler - and we'll take them one piece at a time. For now, it is enough that you realize that things showing up on web pages are actually generated using HTML tags. Most of the time we have software generating the code for us, but we do need to know enough to look under the hood and tweak things when needed.
  • The other purpose of this tutorial is to demonstrate one way to present a tutorial blog post. To see more examples, click the tutorial label (tag) in the label cloud (tag cloud) to the right.
    To see how your tutorial blog posts are evaluated, go here.




Thursday, December 11, 2014

Adding an HTML/Javascript Gadget

A clarification/FYI

First off, in most other blogging platforms, gadgets are usually called widgets -- so if I accidentally lapse into calling them widgets, or if you hear someone else referring to widgets, that's why. In Blogger, they are gadgets - and those are all the little extras you can add to the layout of your blog -- in the header, sidebars, and footer areas.


Let's add a gadget!


Sign in to your blog.  To add a gadget, you go to the Layout section in your left sidebar menu.

Anywhere you see "Add a Gadget", you can click that, which will bring up a dialog box of gadget choices.

In this example, I clicked the "Add a Gadget" to the right of "My Posts".





In the dialog box that comes up, you'll see a list of gadgets you can add.  For this little tutorial, we are choosing HTML/JavaScript.  To add the gadget, click the plus (+).




The configuration box for HTML/Javascript gadget looks like this.  Give your gadget a title.

For the content, I am writing a little blurb about the purpose of this blog, and am making a link to this post you are viewing now.

Making anything bold or italics actually inserts HTML/CSS code to make it.  Don't let that freak you out.

I'm coming back to this gadget, but for now, I'm pressing Save.






Moving a gadget


After saving, my layout now shows my additional gadget to the right of my posts, with my title on it. To return to edit the gadget later, I'll just click on Edit.

I wanted my new gadget below the About Me gadget, so I just clicked on the left vertical gray bar and dragged it down below About Me.

Dragging the gray bars lets you reposition gadgets anywhere in your layout.








After moving my gadget where I want it, I went up to the orange Save Arrangement button to keep what I've done so far.




The result (so far)

Here's what the gadget area to the right of my posts looks like when I view my blog.

You can see the HTML/Javascript gadget ignored my blank lines. That's just an HTML thing - we'll fix that in a minute.

I'm also going to publish this post I'm writing, and then go click on it to see what the URL is for my link (the word "here").  BRB....










Adding a link

OK, I viewed this post and copied the URL from the browser's address window.  It's:
http://studentblogdemo.blogspot.com/2014/12/adding-htmljavascript-gadget.html


Now let's go back to the layout, and edit this gadget again.  You may also instead click the little "tools" icon at the bottom-right of the gadget.


I took out the bold "here!" that I had put in before as a placeholder until I had my actual URL (at the end of the 2nd paragraph.)

I put the cursor there where I wanted my link - and then pressed the link button (to the right of the "i" button.)




Blogger brought up a dialog box for me to paste the URL into. (command-v)

OK.








See the anchor <a...> tag?  That has the URL for the link.  See the ending </a> tag?



That ends the link.  The word "here" that I want clickable, goes in between the two.



I added in my "!" after the closing tag, so that won't be part of the link.

Remember how HTML ignores blank lines? Wrap each paragraph with a <p> tag and a closing </p> tag.  One guess what "p" stands for...  And for the record, "/" is a slash.

The finished result

TA-DAAAA.

The p tags made my blank lines between paragraphs, and my link - the word "here" is now clickable -- linking to this post.

You can make links to whatever you want - your other posts or pages, or other websites.







When to use this gadget

Blogger has a lot of great gadgets to do useful things on your blog.  But, if you need something more custom-made that doesn't really fit one of the other standard gadget types, try an HTML/Javascript gadget.

If you don't need to format your text or make links, you could just use a Text gadget, instead.


Until next time....