Image Alt Tag - Multiple identical Images

Not sure if SEO questions are relevant for StackOverflow. Feel free to correct me if not.

Not sure if SEO questions are relevant for StackOverflow. Feel free to correct me if not.

Have a "quiz" website that shows many duplicate images. For example - when users are going through a "goals" section of the quiz the image stays the same until the section changes.

 <p class= id='question1'> I'm very motivated.</p>

<img id='image1' src='https://i.imgur.com/DfxbRDL.jpg' alt= "Woman shooting bow">

<p class= id='question2'> I want to succeed.</p>

<img id='image2' src='https://i.imgur.com/DfxbRDL.jpg' alt= "Woman shooting bow">

The images are hidden and shown depending on the question.

My question is:

What is the best way to handle this from an SEO standpoint? Just make different alt tags for the same image?

Should I create a variable and somehow use it for the images>

Edge displaying .jpg image as randomly colored square

I have a problem that has just recently occurred, it may be a browser bug in Edge as I am sure it was working previously, but I have some .jpg images that are not showing in Edge (but show fine in IE, Chrome, Firefox) instead all I see is a color (different color for different image - even though there is no background color or any other color attributed - so should be white if image not showing - these images are using styles of radius and shadow, but removing them makes no difference.

I have a problem that has just recently occurred, it may be a browser bug in Edge as I am sure it was working previously, but I have some .jpg images that are not showing in Edge (but show fine in IE, Chrome, Firefox) instead all I see is a color (different color for different image - even though there is no background color or any other color attributed - so should be white if image not showing - these images are using styles of radius and shadow, but removing them makes no difference.

When I right click and save image the correct jpg is downloaded, the link is good, as I say it works on other browsers, but no longer on edge (nothings changed that I know of). Any ideas?

as seen on Edge:

As seen on other browsers:

I have tried removing styles and checked the divs for overlaps or other common problems, everything looks OK.

.sitelinks {
margin: 10px 42px 10px 45px;
padding: 20px 5px 20px 5px;
width: 180px;
vertical-align: top;
display: inline-block;
}
.sitelinks:hover {
background: #CCC;
}
.sitelinks img {
width: 1px;
height: 1px;
box-shadow: 3px 5px 12px #000000;
border-radius: 50%;
}
.sitelinks img:hover {
-o-transform: scale(1.06);
-webkit-transform: scale(1.06);
-ms-transform: scale(1.06);
-moz-transform: scale(1.06);
transform: scale(1.06);
}
.desc {
padding-left: 10px;
padding-top: 10px;
width: 160px;
text-align: center;
font-size: 1.4em;
color: #333;
font-family: 'Quicksand', sans-serif;
font-weight: 600;
}
<div class="sitelinks">
<a href="services.php" target="_self"><img id="link1" 
src="assets/img/services_ico.jpg" alt="Our Services"></a>
<div class="desc"><a href="services.php" target="_self">Our Services</a> 
</div>
</div>
<div class="sitelinks">
<a href="contact.php" target="_self"><img id="link2" 
src="assets/img/contact_ico.jpg" alt="Contact the team"></a>
<div class="desc"><a href="contact.php" target="_self">Contact Us</a></div>
</div>
<div class="sitelinks">
<a href="photos.php" target="_self"><img id="link3" 
src="assets/img/gallery_ico.jpg" alt="Picture Gallery"></a>
<div class="desc"><a href="photos.php" target="_self">Photo gallery</a> 
</div> 
</div>
<div class="sitelinks">
<a href="reviews.php" target="_self"><img id="link4" 
src="assets/img/feedback_ico.jpg" alt="Customer reviews"></a>
<div class="desc"><a href="reviews.php" target="_self">Customer 
testimonials and reviews</a></div>
</div>

There are four images that are the same html

Render HTML with Vanilla JavaScript and lit-html

Render HTML with Vanilla JavaScript and lit-html

Sometimes you need to render HTML elements on a web page. And like Goldilocks' search for "just right", you have to try a few techniques before you find the right one. Using a framework may be too hard. Using pure HTML and the DOM API may be too soft. What you need is something in the middle that is just right. Is lit-html "just right"? Let's find out.

Sometimes you need to render HTML elements on a web page. And like Goldilocks' search for "just right", you have to try a few techniques before you find the right one. Using a framework may be too hard. Using pure HTML and the DOM API may be too soft. What you need is something in the middle that is just right. Is lit-html "just right"? Let's find out.

First, I'll show how this all works. Then at the end of this article, I'll explain everything you need to get started with lit-html to try this for yourself.

When you're done, you can push your HTML app with lit-html to the cloud to see it in all of its glory! I included a link to a free Azure trial, so you can try it yourself.

Resources:

The Sample App

Here is the app I'll demonstrate in this article. It fetches a list of heroes and renders them when you click the button. It also renders a progress indicator while it is fetching.

What's the Value of lit-html

When you focus on rendering content, and nothing else, lit-html is a good fit. It works closely with the DOM to render content, and refresh it in an optimal manner. The docs can provide you with more details, but the basic code for lit-html looks like this.

// Credit: As seen in official docs https://lit-html.polymer-project.org/guide/getting-started

// Import lit-html
import { html, render } from 'lit-html';

// Define a template
const myTemplate = name =>
  html`
    <p>Hello ${name}</p>
  `;

// Render the template to the document
render(myTemplate('World'), document.body);

You import lit-html, define a template, then render it to the DOM. That's it!

Rendering HTML

A progress bar is fairly basic. There is some HTML, and we show it when needed and hide it when it is not required. While we could use a template, or innerHTML, or the DOM API for this, let's see what this would look like with lit-html.

First, we get a reference to the element in the DOM where the progress bar will appear.

Then we define the template. This code looks and feels like JSX (or TSX). The advantage here is that you can write the HTML. You wrap the HTML in a template string (notice the back-tick character is used and not a single quote). Template strings allow you to span lines and insert variables where needed (we'll see this soon). The magic that makes this work is the html tag that precedes the template string. The html tag is what tells lit-html that you are about to define a template.

Next, we compile the template and pass those results to lit-html's render function, which places the results in the DOM. Finally, we hide or show the progress bar as needed.

function showProgress(show = true) {
  const container = document.getElementById('progress-placeholder');

  const template: () => TemplateResult = () => html`
    <progress class="progress is-medium is-info" max="100"></progress>
  `;
  const result = template();
  render(result, container);

  container.style.display = show ? 'block' : 'none';
}

Now you can run this showProgress function any time you want to show the progress bar.

Note that when a template is re-rendered, the only part that is updated is the data that changed. If no data changed, nothing is updated.

Rendering HTML with Dynamic Values

The progress bar does not change each time it is rendered. You will have situations where you want your HTML to change. For example, you may have a message area on your web app that shows a styled message box with a title and a message. The title and message will change every time you show the message area. Now you have dynamic values.

The HTML is defined with a template string, so it is trivial to add a variable into it. Notice the code below adds a title and text into the template, using the ${data.title} and ${data.text} syntax, respectively.

Then the template is compiled and rendered were needed.

When this template is re-rendered, the only part that is updated is the data that changed. In this case, that's the title and text.

function showMessage(text: string, title = 'Info') {
  const template: (data: any) => TemplateResult = (data: Message) => html`
    <div id="message-box" class="message is-info">
      <h3 class="message-header">${data.title}</h3>
      <p class="message-body">${data.text}</p>
    </div>
  `;

  const el = document.getElementById('message-placeholder');
  const result = template({ title, text });
  render(result, el);

  el.style.visibility = !!text ? 'visible' : 'hidden';
}

Rendering a List

Things get a little more real when we render a list. Let's think about that for a moment. A list requires that we have a plan if there is data and a backup plan if there is no data. A list requires that we render the same thing for each row, and we don't know how many rows we have. A list requires that we pass different values for each row, too. Then we have to take the rows and wrap them in a container such as a <ul> or a <table>.

So there is a little more logic here, regardless of whether we use lit-html or any other technique. Let's explore how the replaceHeroList function renders the rows using lit-html.

function replaceHeroList(heroes?: Hero[]) {
 const heroPlaceholder = document.querySelector('.hero-list');

 // Define the template
 let template: () => TemplateResult;

 if (heroes && heroes.length) {
   // Create the template for every hero row
   template = createList();
 } else {
   // Create the template with a simple "not found" message
   template = () =>
     html`
       <p>heroes not found</p>
     `;
 }

 // Compile the template
 const result = template();

 // Render the template
 render(result, heroPlaceholder);

Notice that when there are heroes, we call the createList function. This function begins by creating an array of TemplateResult. So for every hero in the heroes array, we define a template that represents the <li> containing the HTML that displays that respective hero.

Then we create another template that contains the <ul> and embeds the array of hero templates. It's pretty cool that we can embed templates like this! Finally, we return it all and let the logic compile the templates and render them.

function createList() {
  // Create an array of the templates for each hero
  const templates: TemplateResult[] = heroes.map(hero => {
    return html`
      <li>
        <div class="card">
          <div class="card-content">
            <div class="content">
              <div class="name">${hero.name}</div>
              <div class="description">${hero.description}</div>
            </div>
          </div>
        </div>
      </li>
    `;
  });

  // Create a template that includes the hero templates
  const ulTemplate: () => TemplateResult = () =>
    html`
      <ul>
        ${templates}
      </ul>
    `;
  return ulTemplate;
}

Summary

When you want to render HTML, lit-html is a fast and light-weight option. Is it better than using templates and the DOM API? You'll have to decide what is best for you. But the real story here is that you have another great option to consider when determining the right tool for your job.

Prologue

You can also get editor help with your lit-html templates. Notice the image below shows the syntax highlighting for the HTML template!

Setup

You can install the lit-html package with npm.

npm install lit-html

Alternately you can load it directly from the unpkg.com CDN

import { html, render } from 'https://unpkg.com/lit-html?module';

You have a choice here. npm is my preference, but feel 100% free to use the CDN if that suits you.

TypeScript and lit-html

You only need to include the library for lit-html and you're done. But I like to use TypeScript, and I absolutely recommend enabling your tooling to work great with typeScript and lit-html.

Let me be very clear here - you do not need TypeScript. I choose to use it because it helps identify mistakes while I write code. If you don't want TypeScript, you can opt to use plain JavaScript.

Here are the steps to make TypeScript and lit-html light up together:

  1. Install TypeScript support for lit-html
  2. Configure your tsconfig.json file
  3. Install the VS Code extension for lit-html

Run this command to install the plugin and typescript, as development dependencies to your project.

npm install --save-dev typescript-lit-html-plugin typescript

Edit your tsconfig.json by adding the following to your compilerOptions section.

"compilerOptions": {
  "plugins": [
    {
      "name": "typescript-lit-html-plugin"
    }
  ]
}

Finally, install the VS Code extension for lit-html.

Now you get syntax highlighting for all of your lit-html templates!

Bootstrap 4 card-Image-overlay text flowing out of image

I have this image with text overlayed, Not sure what causing it, but on mobile (small/xs)the play button and title is getting out of the image due the p text being long. what bootstrap class am i messing up to cause this issue? I thought the image height will adjust to take care of this issue when texts inside gets longer, is it the image?.

I have this image with text overlayed, Not sure what causing it, but on mobile (small/xs)the play button and title is getting out of the image due the p text being long. what bootstrap class am i messing up to cause this issue? I thought the image height will adjust to take care of this issue when texts inside gets longer, is it the image?.

html {
  font-size: 18px;
}
@media (min-width: 576px) {
  .container {
    max-width: 540px;
 }
}
@media (min-width: 768px) {
  .container {
    max-width: 720px;
 }
}
@media (min-width: 992px) {
  .container {
    max-width: 960px;
 }
}
@media (min-width: 1200px) {
  .container {
    max-width: 1400px;
 }
}
h1, .h1 {
  font-size: 3.815rem;
}
h2, .h2 {
  font-size: 2.441rem;
}
h3, .h3 {
  font-size: 1.563rem;
}
h4, .h4 {
  font-size: 1.25rem;
}
.product-video-section .product-video-container {
  position: relative;
}
.product-video-section .product-video-container video {
  height: auto;
  vertical-align: middle;
  width: 100%;
}
.product-video-section .product-video-container #product-video-button {
  color: #d4272e;
}
.product-video-section .product-video-container .product-video {
  display: none;
}
.product-video-section .product-video-container .product-video-texts .play-btn-wrap {
  text-decoration: none;
  background-color: #fff;
  border: 1px solid #d4272e;
  display: inline-block;
  border-radius: 50%;
  width: 3.5rem;
  height: 3.5rem;
  color: #d4272e;
  transition: all 300ms ease-in;
  cursor: pointer;
}
.product-video-section .product-video-container .product-video-texts .play-btn-wrap i {
  font-size: 2rem;
}
.product-video-section .product-video-container .product-video-texts .play-btn-wrap:hover {
  background-color: #d4272e;
  transition: all 300ms ease-in;
  transform: scale(1.2);
}
.product-video-section .product-video-container .product-video-texts .play-btn-wrap:hover i {
  color: #fff;
}
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>

&lt;script src="https://code.jquery.com/jquery-3.3.1.js" integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60="
    crossorigin="anonymous"&gt;&lt;/script&gt;
&lt;script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy"
    crossorigin="anonymous"&gt;&lt;/script&gt;
&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
    crossorigin="anonymous"&gt;&lt;/script&gt;
&lt;script src="./Library/bower_components/slick-carousel/slick/slick.min.js"&gt;&lt;/script&gt;
&lt;script src="./index.js"&gt;&lt;/script&gt;
&lt;script src="https://unpkg.com/[email protected]/dist/ionicons.js"&gt;&lt;/script&gt;


&lt;link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
    crossorigin="anonymous"&gt;
&lt;link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"
    integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous"&gt;
&lt;link rel="stylesheet" href="./Library/bower_components/slick-carousel/slick/slick.css" /&gt;
&lt;link rel="stylesheet" href="./Library/bower_components/slick-carousel/slick/slick-theme.css" /&gt;

&lt;link href="http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css" rel="stylesheet"&gt;

&lt;link rel="stylesheet" type="text/css" href="./style/index.css"&gt;

</head>

<body>

    &lt;div class="product-video-section "&gt;
        &lt;div class="product-video-container card"&gt;
            &lt;img src="https://www.dropbox.com/s/5x8p2z5cvip5u38/chicago.jpg?dl=1"&gt;
            &lt;div class="card-img-overlay  d-flex align-items-center product-video-texts text-dark" id=""&gt;
                &lt;div class="row"&gt;
                    &lt;div class="col-12"&gt;
                        &lt;div class="d-flex justify-content-end row"&gt;
                            &lt;div class="col-lg-6 col-sm-12"&gt;
                                &lt;h4 class="card-title "&gt;This is video&lt;/h4&gt;
                                &lt;p class="card-text "&gt;
                                    
                                    Lorem ipsum dolor sit amet consectetur adipisicing elit. Officia sint dolore nemo deserunt voluptatum animi omnis corrupti nam recusandae aliquam, amet ullam qui sequi assumenda, eius, debitis iusto voluptas perferendis!
                                    Lorem ipsum dolor sit amet consectetur adipisicing elit. Officia sint dolore nemo deserunt voluptatum animi omnis corrupti nam recusandae aliquam, amet ullam qui sequi assumenda, eius, debitis iusto voluptas perferendis! sit amet consectetur adipisicing elit. Officia sint dolore nemo deserunt voluptatum animi omnis corrupti nam recusandae aliquam, amet ullam qui sequi assumenda, eius, debitis iusto voluptas perferendissit amet consectetur adipisicing elit. Officia sint dolore nemo deserunt voluptatum animi omnis corrupti nam recusandae aliquam, amet ullam qui sequi assumenda, eius, debitis iusto voluptas perferendis!!
                                
                                &lt;/p&gt;

                                &lt;div href="" class="play-btn-wrap d-flex justify-content-center" data-toggle="modal"
                                     data-target="#@videoTarget"&gt;
                                    &lt;i class="ion-ios-play product-video-button  align-self-center pl-1" id="" aria-hidden="true"&gt;&lt;/i&gt;
                                &lt;/div&gt;
                            &lt;/div&gt;
                        &lt;/div&gt;
                    &lt;/div&gt;

                &lt;/div&gt;
            &lt;/div&gt;
        &lt;/div&gt;
    &lt;/div&gt;

</body>

</html>