Tips for arranging HTML image sources to prepare for future updates

Incorporated into the HTML are a series of images, each accompanied by text and/or transitions. To streamline positioning, each image set along with other elements (text, video, etc...) is enclosed within a div. Furthermore, every image is labeled with a number similar to those found in magazines or books. Let's assume there are 30 pages for the sake of discussion.

Subsequently, I am given a new page from the art department, which happens to be the fourth page, pushing the subsequent pages back by one. Additionally, for organizational purposes, the img files must be renamed as well (e.g. img-20-jpeg is now img-21-jpeg).

I am seeking a solution to avoid manually renaming classes for each div, img, paragraph in both the HTML and CSS.

I have attempted to disregard specific numbers in image sources and reference the CSS styling for each "page" using the nth-child selector. Moreover, I have tried to associate each package of text, effects, etc... with its immediate parent "page" using ~.

Unfortunately, my attempts have only resulted in significant headaches.

<div class="page">
  <img class="page" src="photo/img.001.jpeg" alt="1">
  <p class="text-page-1">
     some text
  </p>
</div>
<img class="page" src="photo/img.002.jpeg" alt="2">
<img class="page" src="photo/img.003.jpeg" alt="3">
<div class="page">
  <img class="page" src="photo/img.004.jpeg" alt="4">
  <video class= "video-page-4" src="video/4.mov" controls playsinline loop></video>
</div>
<div class="page">
  <img class="page" src="photo/img.005.jpeg" alt="5">
  <p class="text-page-5">
     some other text
  </p>
</div>

Answer №1

Here are a couple of suggestions to improve your coding structure.

  1. Avoid using numbering and instead use comments to keep track. Also, consider changing hard-coded classes like text-page-1 to include a paragraph inside the class page: .page p or .page > p.
<!--page 1-->
<div class="page">
    <img src="photo/img.001.jpeg" alt="1">
    <p>
        some text
    </p>
</div>
<!--page 2-->
<div class="page">
    <img src="photo/img.0045.jpeg" alt="1">
    <p>
        some text
    </p>
</div>
  1. Consider using old-school numbering techniques by starting at 10 and going up by increments of 10 or even 100. This way, you can easily insert new pages without having to renumber everything.
<div class="page">
    <img src="photo/img.10.jpeg" alt="1"> <!--start at 10.-->
    <p class="text-page-10"> <!--use class only if necessary-->
        some text
    </p>
</div>
<!--you can now insert a new page here using numbers 11-19.-->
<div class="page">
    <img src="photo/img.20.jpeg" alt="1">
    <p class="text-page-20">
        some text
    </p>
</div>

Answer №2

Feel free to utilize this snippet of code

    <!--page 1--> 
    <div class="page">
        <img class="page" src="photo/images/img1.jpeg" alt="1">
        <p class="text-page-1">some text</p>
    </div>
    <!--page 2-->
    <div class="page">
        <img class="page" src="photo/images/img2.jpeg" alt="2">
        <img class="page" src="photo/images/img3.jpeg" alt="3">
    </div>
    <!--page 3-->
    <div class="page">
        <img class="page" src="photo/images/img4.jpeg" alt="4">
        <video class= "video-page-4" src="video/4.mov" controls playsinline loop></video>
    </div>
    <!--page 4-->
    <div class="page">
        <img class="page" src="photo/images/img5.jpeg" alt="5">
        <p class="text-page-5">some other text</p>
    </div>

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

What could be causing the undefined status of this length function?

I need to determine the length of seconds. If the second is only one character long, I want to add a 0 in front of it. Otherwise, no action is needed. Below is my code: <p>Click the button to show the current number of seconds.</p> <p id= ...

What is the method to obtain the coordinates based on a city name, and subsequently store those coordinates in a variable?

I'm currently exploring ways to extract the geographical coordinates based on user-provided city names. I am aware that Google offers this functionality through their API, but I am struggling with how to actually capture and store these results in PHP ...

navbar item arranged in a row using Bootstrap 5

I am looking to create a fixed top navbar with just one row, instead of two rows. Here is the code I currently have: <div class="col-md-3"> <ul class="navbar-nav mb-2 mb-lg-0"> <li class="nav-item"&g ...

The left border is failing to appear on the Td element

When attempting to add border styling to td elements, the left border is not displaying correctly. This issue seems to vary across different browsers. Here is the HTML code: <table class="table-bordered"> <thead> <tr> ...

Executing JavaScript function by clicking on <img>

I've been developing a website similar to YouTube, and I'm facing difficulties with the Like/Dislike feature for comments. Currently, I have implemented it in the following way: when a user clicks on an image (thumbsUp.png or thumbsDown.png), a ...

What is the deal with CSS relative magnification?

I am currently utilizing a PHP styleswitcher along with alternate stylesheets in an attempt to replicate the functionality of browser zoom (done using keyboard shortcuts cmd-plus or ctrl-plus). At the moment, when clicking on the "zoom in" graphic, it is ...

Guide to invoking an HTML document through PHP

I'm currently in the process of developing an administrator login page using a combination of HTML and PHP, with PHP serving various other functions as well. Once the administrator successfully logs in, I need to execute an HTML file. Below, you&apos ...

is it possible to adjust the height of a tableRow in mui?

I recently created a table component using Mui. I've been attempting to adjust the height of the tableRows, but so far I haven't had any success. Below is my code snippet: import React, { memo } from "react"; import { ActionItemType, ...

Emphasize the checkbox

In my table, I have radio buttons that should turn the neighboring cell green when clicked. Using JQuery, I added a "highlight" class on $.change event to achieve this effect. However, I encountered an issue where some radio buttons load with the "checked ...

I'm having trouble getting things to line up properly in Bootstrap5. Can anyone help me figure out why?

When observing this layout, there seems to be a vertical misalignment. The button slightly overflows, while the input field does not. https://i.sstatic.net/pEw2U.png What could be causing this issue? I am currently utilizing Bootstrap 5.2.3 and have incl ...

Avoid automatic background resizing to match the full width of the header text

I've been trying to use CSS to style my <h1> element in a specific way, but it seems the default browser behavior is getting in the way: Despite my efforts, the browser continues to display it like this: Anyone have any suggestions on how I ca ...

"Enable a smooth transition and switch the visibility of a div element when clicked

How to create a dropdown form with a transition effect that triggers on click of an element? Once triggered, the transition works smoothly but clicking again only hides the div element without triggering the transition. See the demo here: Check out the fu ...

Using AJAX to showcase data from a table in a database using the <select> tag but with an unfinished submit process

I am encountering an issue with my code. When I submit the value in getinv.php, it only returns a partial value. For example, when I click '2016-08-27', it only retrieves '2016'... My question is, how can I ensure that the exact value ...

Retrieve information from a JSON API on one server and showcase it on an HTML page hosted on a different server

I have a situation where I need to transfer data from one project (Project1) to another project (Project2). To achieve this, I decided to convert the Project1 data stored in a database into a JSON API and then call it using an HTML page from Project2. Howe ...

Text will not be displayed when it is written on images

I'm currently facing a challenge with adding text onto two different images, one on the left and one on the right. I have included HTML and CSS code but it seems to be incorrect. Can someone please help me fix it? #container { width: 400px; hei ...

Border at the Top and Text Alignment Problem

I am working on a basic navigation bar that includes a hover effect. .navip { float: left; text-decoration: none; font-weight: lighter; } .navip > a { display: block; color: black; text-decoration: none; font-size: 20px; ...

The webpage is not displaying any results despite using .innerHTML with Ajax

I am currently developing a web application that displays query results using the Google Books API. While my code is functioning, I am encountering an issue where the .innerHTML method does not show any results on the HTML page. Below is the HTML code bein ...

Something seems off with Chrome

I am facing a unique issue that I need help with. Unfortunately, the code is too long to post here but essentially it involves creating a menu for a website. The menu works perfectly and looks great on all browsers except for Chrome. This is unusual as Ch ...

AngularJS Input field fails to update due to a setTimeout function within the controller

I am currently working on a project that involves AngularJS. I need to show a live clock in a read-only input field, which is two-way bound with data-ng-model. To create this running clock effect, I am using a JavaScript scheduler with setTimeout to trigge ...

Is there a method to instruct crawlers to overlook specific sections of a document?

I understand that there are various methods to control the access of crawlers/spiders to documents such as robots.txt, meta tags, link attributes, etc. However, in my particular case, I am looking to exclude only a specific portion of a document. This por ...