Combining the power of HTML5's picture tag with the flexibility of Bootstrap

I have been wanting to gain more control over my images on various screen sizes for quite some time now. Recently, I discovered the <picture> tag in HTML5.

Currently, I am using Bootstrap 3. However, I'm not sure if it is effective to combine Bootstrap and the <picture> tag. So far, I haven't noticed any significant changes in the test code I created.

<!DOCTYPE html>
<html lang="en>
<head>
  <title>TEMPLATE</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

<style>
</style>
<body>
<div class="container-fluid">
  <!-- Test row 1 -->
  <div class="row">
    <div class="col-sm-12">
      <picture>
        <source media="(min-width: 991px)" srcset="http://vouzalis.dk/1024.jpg">
        <source media="(min-width: 768px)" srcset="http://vouzalis.dk/991.jpg">
        <source media="(min-width: 650px)" srcset="http://vouzalis.dk/768.jpg">
        <source media="(min-width: 380px)" srcset="http://vouzalis.dk/380.jpg">
        <img src="http://vouzalis.dk/1024.jpg" alt="Test picture" style="width:auto;">
      </picture>    
    </div>
  </div>
  <!-- Test row 2 -->
  <div class="row">
    <div class="col-sm-6">
      <picture>
        <source media="(min-width: 991px)" srcset="http://vouzalis.dk/1024.jpg">
        <source media="(min-width: 768px)" srcset="http://vouzalis.dk/991.jpg">
        <source media="(min-width: 650px)" srcset="http://vouzalis.dk/768.jpg">
        <source media="(min-width: 380px)" srcset="http://vouzalis.dk/380.jpg">
        <img src="http://vouzalis.dk/1024.jpg" alt="Test picture" style="width:auto;">
      </picture>    
    </div>
    <div class="col-sm-6">
      <picture>
        <source media="(min-width: 991px)" srcset="http://vouzalis.dk/1024.jpg">
        <source media="(min-width: 768px)" srcset="http://vouzalis.dk/991.jpg">
        <source media="(min-width: 650px)" srcset="http://vouzalis.dk/768.jpg">
        <source media="(min-width: 380px)" srcset="http://vouzalis.dk/380.jpg">
        <img src="http://vouzalis.dk/1024.jpg" alt="Test picture" style="width:auto;">
      </picture>    
    </div>
  </div>
</div>
</body>
</html>

Answer №1

Is it logical to utilize Bootstrap and the image tag together?

In my opinion, the answer may vary depending on whether you have a CMS that can generate scaled images/thumbnails dynamically and how many images will be displayed on the page.

If there are only a few images and you're working with static HTML, it might be best to load one image and apply Bootstrap's fluid-img class for responsive design. Otherwise, using the image tag as is should not pose any issues.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for extracting header ID from the HTML/DOM using react and typescript

I developed a unique app that utilizes marked.js to convert markdown files into HTML and then showcases the converted content on a webpage. In the following code snippet, I go through text nodes to extract all raw text values that are displayed and store t ...

Creating personalized CSS styles specifically designed for iPad Mini 2 with a retina display and optimizing it for different screen/viewport settings

Struggling to assign different colors for various screen sizes, I'm facing a perplexing issue with the iPad Mini 2's Retina Display. Despite its pixel resolution, it doesn't conform to the specified rules and I'm left wondering why. Th ...

Conceal overflow content within a Bootstrap btn-group using CSS styling

Suppose I have a table like the one below: /* CSS Styles for the table */ table.my { width: 600px; } table.my > tr { height: 40px; overflow: hidden; } .tag { background: #b8b8b8; padding ...

Tips for displaying specific HTML elements in AngularJS using ng-repeat and ng-if

I am working with some bootstrap HTML code that includes an ng-repeat function. <div class="row"> <div class="col-lg-4" ng-repeat="p in persons"> <img class="img-circle" src="images/{{ p.image }}" width="140" height="140"> < ...

What is the best way to add a dropdown menu in front of a button?

I have a div containing a dropdown list of items and I want the user to be able to add more dropdown lists by clicking a button. Although I managed to do this, the issue I'm encountering is that the new list gets added after the button instead of ben ...

Tips for aligning images in the center of a webpage across various screen sizes

I'm encountering an issue with my HTML code. Despite extensive searching online, I have yet to find a suitable solution. The problem lies with the alignment of images on my website. Although they appear centered on my screen, this is due to manually ...

Issue with iOS 10: Changes to class not reflected in CSS/styles

Currently, I am utilizing Ionic with Angular to develop an application for Android and iOS. Surprisingly, everything functions smoothly on Android, but there seems to be an issue with iOS. I am employing a class change on an element using ng-class. I can ...

Adjust the height of images to be consistent

I'm currently working on creating a grid layout with 4 images in a row using DaisyUI card component. However, I've run into an issue where there is white space at the bottom of some images due to varying image heights. Is there a solution that wo ...

Can we incorporate <a> tags in XML as we do in HTML?

Currently, I am honing my XML skills. I am planning to incorporate the <a> tag within the XML file in order to create a hyperlink to another webpage. ...

Issues arising with transferring information between components

My webpage had a header with a search engine input, a list of posts, and pagination all on one page. I made the decision to separate the header into its own component in a different Vue file. However, after making this change, searching for posts by their ...

Divide the table header column "th" into two separate columns

Can someone assist me in achieving the output displayed in the image? I want to separate the header th into two lines like the blue line shown. I need two headers for a single td column. Please help, thank you. https://i.sstatic.net/SwILH.png <style& ...

Trouble locating the elusive element with Selenium

Currently, I am working on creating a framework that involves determining whether a web element is hidden before executing any actions on it. One specific scenario involves a password field that is structured like so: <div class=hidepassword> < ...

What is the best approach to determine the value of a textbox in an array for each row of

I am trying to display the total sum of values for each row in a data array. There are 5 rows of data, and I need to calculate the results for each one. Can someone assist me in solving this? function calculateTotalValue(){ var total = (document.get ...

The CSS property that controls the background color of an element

This syntax for a CSS background property is quite effective: .my-element { background: linear-gradient(rgba(131,131,131,0.8), rgba(98,98,98,0.8)), url('img/background.jpg') } However, I am not looking for a gr ...

The python parser extracts symbols from HTML instead of words

Currently attempting to extract data from a website's HTML using lxml and XPath. The process appears to be functioning correctly, however it is yielding results that are not expected : from lxml import html import requests page = requests.get(' ...

A guide on revealing the Inspect tab in Figma

I accessed a figma layout. enter image description here However, the Inspect tab is missing on the right side of the Design and Prototype tabs. How can I make it visible? I am in need of assistance with the Figma interface. Additional content... ...

Tips for aligning 2 columns perfectly in a 3 column layout

I am facing an issue with a grid section where the grid-template-column is set for 3 columns, but sometimes the content loaded dynamically only fills 2 columns. I am attempting to center the columns when there are only 2. Despite going through the grid CS ...

Filtering dynamically generated table rows using Jquery

I'm currently working on a project that involves filtering a dynamic table based on user input in a search bar. The table contains information such as name, surname, phone, and address of users. Using jQuery, I have created a form that dynamically ad ...

JavaScript's Ajax request encounters issues while running on Internet Explorer

Here is the code I'm using to retrieve data objects from a remote site and display them on another site. While this code works perfectly in Chrome and Firefox, it throws a "Permission denied" error in IE. I've tried adding Access-Control-Allow- ...

Navigating through images within my application

When setting images, I encounter an issue where the second image overlaps the first one instead of appearing separately. How can I ensure that each image is displayed in its own box? I have attempted to use a blob directly by returning imgUrl in the showI ...