Hiển thị các bài đăng có nhãn HTML. Hiển thị tất cả bài đăng
Hiển thị các bài đăng có nhãn HTML. Hiển thị tất cả bài đăng

Chủ Nhật, 23 tháng 6, 2019

Telling Google, and visually-impaired people, about the pictures in your blog

This article is about why and how to attach keywords and related text to the pictures in your blog posts.  This is helpful for both search engine optimisation (SEO), and for making your blog accessible to people who use screen-reader software.

Pictures and your blog

Blogger has a set of tools for putting pictures into your blog, including several options for putting images into posts or gadgets. 

In most cases, the other content in each post provides enough information for Google's indexing tools to know what the post is aobut.

But if your blog mainly has photos, your posts may not have enough key words to get properly indexed.  And even if the image-indexing tools do some auto recognition, a description of a picture written by a human being  will almost always be better than one which was created by a computer.

Also, if your blog's visitors may include visually impaired people or others who use screen-reader software, then you need to think about how well your content will work for them:  if you important information is inside images but not in the text, then they won't be able to get this information in any way.

These two good reasons for adding "alternate text" to your pictures - and there may be more.

What's even better is that Blogger now has a tool for to make it easy to do this.



How to add captions and alt-text to pictures in Blogger


Add the picture to your Post.

In Compose mode, float your mouse over the picture.   This will show the picture-editing-toolbar, like this:



Choose the Properties option.

This opens a dialog box where you can enter
  • A title - this is shown when a visitor hovers their mouse over the picture
  • Alt text - this is kept in the background, and only displayed to people who (for whatever reason) cannot see the picture.




What your readers will see

People who read your blog on line, either with a standard browser or an RSS feed reader, won't see anything different, until they hover over the photo.   When they hover, they will see the text you put into the Title field.

People who read your blog in their email (because you've offered a subscribe-by-email option) may see the alt text instead of the picture, depending on what setting they have in their email system.

People who use screen reader software will have the text that you added read out to them in the usual way that their software works.

And most importantly, search engines will see the text you added, and hopefully the will use it in indexing your post.



Other Alternatives

The Post and Pages editor also has an Add Caption option on the photo toolbar, although I only recommend using  if you're comfortable editing HTML, because it puts the picture into a table, and so to move it inside the post you need to edit the code, not just drag-and-drop it.



Related Articles

Tools for putting pictures into your blog

Addingng a Picasa slideshow to your blog

Tools for applying copyright protection to your blog

Why RSS/Subscribe to Posts is important for your blog.

Adding a subscribe-by-email option to your blog

Thứ Hai, 31 tháng 10, 2016

How to center gadgets in Blogger

This article is about centering gadgets from 3rd parties that you install onto your blog.



Previously, I've described how to put HTML code from a 3rd party into your blog.

When code like this is put into a gadget, one common question is "how do I center it?"

There are (at least) three options for doing this, ie for putting a gadget into the middle (horizontally) of the area it is located in.   These are described below.


Option 1: Centre all the gadgets in your blog

To center-align every single gadget in your blog, just, add a CSS rule to your blog.  The rule to add is:
.widget {
  text-align: center;

This will centre the contents and title of every gadget on your blog.


Option 2: Only center-align the specific gadget

To only centre-align one gadget, which is made from HTML/Javascript code, you can just put the gadget-code from the 3rd party (eg PayPal, Amazon, etc) inside a centering statement, like this:

<div style="text-align: center;">

PUT THE CODE FROM THE 3RD PARTY HERE

</div>
Install the code into your blog the way you would usually install this 3rd party code.

This will centre-align the contents (not title) of the specific gadget that you add.

Note the American spelling of the word "center" - and don't forget to put the closing </div> statement at the end.

There may be some gadgets where it would be possible to add the centring statement to the gadget code itself, rather than putting it outside.    I don't recommend this (unless you're so comfortable with HTML and CSS that you don't need to be reading this article), because it introduces a risk that you will interfere with some other aspect, or that you will lose the centering if you ever need to refresh the code.


Option 3 - Make a new style rule just for the gadget

If you only want to centre one (or several) gadgets - not all of them - then it's best to define a new style that is to be used on specific gadgets:  put this new style into your template, and then apply it to the gadgets like this.
<div class="YourNewSytle">

PUT THE CODE FROM THE 3RD PARTY HERE

</div>

This approach will only centre the gadget contents - not any header that you give to it.

There are lots of options that you could put into the new style rule, but at a minimum it needs to have
.YourNewStyle
{
  text-align: center;
}
Notice that there is a "." (ie a full-stop) before the name of your new style.

Also, it's best not to use a number as the style-name (eg "2nd-gadgetStyle"), because this doesn't work with some browsers.




Related Articles

Putting HTML code from a 3rd party into your blog

Adding a new CSS style into your template

Centering the header in your blog

Putting a gadget above your blog's header

Removing the attribution gadget from Designer-template blogs 

Thứ Năm, 6 tháng 10, 2016

Getting the HTML code to put a picture into your blog's sidebar, header or footer

This article explains how to use Blogger's Post Editor to get the HTML code that you need to put a picture into your sidebar (or header or footer, or anywhere else a gadget can go).




The Picture gadget is the normal tool for adding a picture to your blog's sidebar.

But sometimes you want more control over the picture size or behaviour.  Eg, you may want to have two pictures very close to each other and guarantee that they're the same size.

To do this, you need to get the HTML code for the picture, and then put it into your blog as an HTML-gadget.  Fortunately, Blogger's Post-editor make it very easy to do this without writing the code yourself.


Using the Post Editor to generate the HTML for a picture

1  Start a new Post  (you're not ever going to publish this:  it's just a work-area)

2  Don't enter any text:   just use the Picture icon on the toolbar to add a picture.   Blogger will prompt you to upload the picture, or to choose it from a Google-album-archive or to enter its URL:  add the picture the way that you usually would.

3  Switch to the HTML tab   (top left of the editing window).

This show you the HTML code for displaying the picture, as it is set to display in the Post (depending on the picture-settings you've chosen, it may be centered or right/left aligned, and the size may vary).

Copy the HTML.

5  Switch back to Compose, so that you don't get confused the next time you edit a post.

Return to the list of posts:  you may be asked if you want to leave the page without saving - the answer is Yes.  Or you may have a new draft-status post, which you can delete.



Job Done!   You now have some HTML code which you can paste into an HTML/Javascript gadget, or anywhere else that you may need it - even into another post that you are editing in a separate window, or into a totally different tool.



Related Articles

Stopping pictures on your blog from being "clickable"

Inserting a Picture into a blog Post.

Putting 3rd party HTML into your blog

Center-align the gadgets on your blog

Hosting pictures outside of Google / Picasa

Inserting a picture into your blog as a gadget

Thứ Hai, 4 tháng 8, 2014

Putting pictures side-by-side in a blog post or gadget

This article shows how to put pictures side-by-side in Blogger (or any other website) using HTML, in a way that works for visitors using mobiles (smartphones and tables) as well as larger screens.



Placing pictures side by side in Blogger:  a picture of three images next to each other on the same line
Previously I've explained how to use a table to force photos (and other things) to all show into a line, even if the user's screen is too small to display them all at once.   And I've looked at putting text and pictures side-by-side - assuming you're only working with one picture.

Tables are great if you are showing data and need rigid alignment, or if you don't mind your mobile device visitors having to either scroll, or to pinch their screen so much that they cannot read the text.

But there is a way to lay out pictures so that they display side by side if there's room on the screen, or start on a new line if there's not.

I've done this recently on a blog where really wanted to make a display for last / next week and last / next year on two different dimensions. It looks like this on a smartphone vs a tablet.   Notice that on the tablet, the two middle pictures are on the same line.




How to lay out several pictures side-by-side if there's space, or one-under-another if not

Start to prepare your post in the usual way.

Add your pictures to the post in the usual way. Ideally, put them just before or just after some marker text that you can use to help you to find the code for it in the next step.

Hover over each picture, and choose the small size (you can change this later)

Go into HTML mode.

Find the place where the pictures are.   (If you've used marker-text, just use your browser's search feature to go to it.)

Add this code, just where you want the line of images (or other items) to end up.
<div style="display: inline-block; margin-bottom: 2em; margin-right: 2em; width: NN;">
IMAGE CODE FOR PICTURE</div>
<div style="display: inline-block; margin-bottom: 2em; margin-right: 2em; width: NN;">
IMAGE CODE FOR PICTURE</div>
<div style="display: inline-block; margin-bottom: 2em; margin-right: 0em; width: NN;">
IMAGE CODE FOR PICTURE</div>

That has space for three pictures - you can delete one or add more lines if you want to - just make sure that the very last one has margin-right: 0em; and the others all have margin-right: 2em;

Now, for each picture that you added,
  • Find the HTML code for it.   (This post has a detailed explanation of what the HTML code for a picture)
  • Delete the height = "nn"  part from it   (nnn = whatever number is there)
  • In the width = "nnn" part, replace nnn with  "100%", so it says   width = "100%"
    Note:  this is saying to make the picture take up the whole width of the division you have assigned it to.   You can make it smaller than 100%.   But you want to do it put a bigger margin between the two pictures, then you can do this by increasing the value in   margin-right: 2em;      
  • Move the picture code to where it says IMAGE CODE FOR PICTURE
  • Decide how wide the picture should be, and change the value in Width: NN within that DIV statement to the right amount.
    You can either use pixels (eg width: 100px;), ems (eg width: 20em;) or percentages (width: 40%;)   If you use percentages, then the total amount for all the pictures should be a little less than 100%, so allow for some space between the pictures:  for example, with a 2em margin and three pictures in a row, you may need to make the total approx 90%.

Go back into Compose mode, and check that your pictures look roughly right - if necessary, you may need to adjust the picture sizes.   (See the note below under Troubleshooting for more about this.)
Delete the marker text.


Job done!   Your pictures will now display side-by-side if they can all fit into the user's screen, or one under another if not.


Troubleshooting

Getting the pictures right can be quite fiddly, so I recommend preparing the blog post in private, so you can do this in stages, and save your work regularly as you go.

Your pictures will be vertically aligned on the bottom axis, and this means that the approach will work best with pictures that are the same height.    (I'm working on another article looking at alignment issues - it's they're quite tricky.)

Post editor view vs your visitor's screen

An issue that many new bloggers struggle with is that what they can see in the post editor is not the same as what their blog-visitors will see.

The post editor screen is only a certain width.    Most times, it is smaller than the width of the main body of your blog.  So, if you have used fixed-widths (ie in pixels, or ems, not percentages), more pictures fit on the same line in your blog than in the post editor. But if a visitor is using their smartphone to read your blog (and I do a lot of my blog-reading on the phone these days) - the screen width is less than it is in the post editor.

This is why using <div> statements instead of <table>'s is a good idea.  But it does means that sometimes you will have to compromise on whether things can be put together.

Is this only for pictures?

No - you can use this technique with blocks of text, videos - in fact anything that you can put into your blog.

What about gadgets?

You can use this technique anywhere that you can edit the HTML.  So, you can put pictures in a row in your sidebar, header or footer by using a HTML-gadget.    (This post shows a handy way to get the picture code when you're making gadgets.)

Captions

don't recommend using captions with this this technique.   Blogger shows them using tables:  they put the photo and text into a one-column-two-row table, and this makes working with the picture code a lot more difficult.   If you really want to use them, then add them after you have moved your picture code inside the <div>...</div> statements.




Related Articles:


Using a table to display data in your blog

Marker text helps you to find places in your blog post

Putting text and photographs side-by-side 

How to add a picture to a blog post

How to get the HTML code for a picture when you don't have an insert-picture icon on the toolbar

Thứ Hai, 21 tháng 7, 2014

Find things in your blog-posts' HTML by using temporary "marker text"

This article shows how to use "marker text" to help find things when you need to edit the HTML code behind one of your blog posts.



When you edit a post in Blogger, to start with you generally use the Compose mode, which shows you the formatted view of how your work will look.

But behind that formatted view, every post is actually written in HTML, ie Hyper-text Markup Language - a type of computer language that uses tags like <h2> or <a href="www.foo.com">  to say how to display the contents.

A number of articles, here and in other blogger-helper blogs tell you how to do thing by changing the HTML for the post. But if you are not used to working with HTML, it can be confusing tryign to fix the part that you need to change.

Marker-text is a technique that you can use to "mark" problem areas while you are still in Compose mode, so that you can easily find them again when you are in Edit HTML mode.


How to use marker-text to fix a problem in your post


Start to prepare or edit your post in the usual way.

Go to the place just before the problem you want to fix or change you want to make.

Add some extra blank lines.

In the middle of the extra blank lines, put a few characters or a word that do not occurr anywhere else in your post. I quite often use XXX - but you can use any letters, characters or numbers, for example PROBLEM JUST AFTER HERE or 12345.

Use the copy function to put the text you added (without the blank lines)into your computer's memory.

Optional: Go to the place just after the problem you want to fix or change you want to make, and add some more text eg PUT IT BEFORE HERE

Switch to Edit HTML mode, using the button at the top-left of the post editing window.

Start the "find" feature in your web browser:
  • ctrl / f in Chrome
  • ctrl / f in Internet Explorer

In the search box that opens, use Paste (ctrl / v) to put the exact marker text that you entered into the Find box, and press enter.

The post-edit window will scroll to the place where your marker text is, and it will most likely be highlighted.

You have now found the place where you need to work, so you can now make the HTML changes required.

Once you have fixed all the issues, switch back to Compose mode using the tab in the top left hand corner, and remove all the marker text and extra blank lines that you added.


Good Practise

You will be removing the marker text before you publish your post.

But just in case you accidentally click Publish before you mean to, only use text that would not be embarrassing if some of your readers accidentally see it.

Some RSS readers will see the contents of your post as they are when you first hit Publish, even if you edit them less than two minutes later.)




Leaving your Marker Text in Place

If you might need to find the same place in your post's HTML again, then instead of removing your marker-text, you may just want to comment it out.

To do this, put these characters before it:
<!-- 

and these characters after it
 -->

So it might look like this

<!-- START OF PROBLEM1 HERE -->

Make sure you get the spaces - highlighed in yellow   as well as both of the "-- characters.

If you do this, then you will not be able to see or find your Marker Text when you are in Compose Mode, but you will be able to see and find it when you are in Edit HTML mode.





Related Articles:

How to edit a post you have already published

Using cut, copy and paste in the Blogger post editor

The Blogger-helpers search tool