Is it possible to anchor with a page that has already been anchored

Let me start by saying that I have very limited knowledge of html, CSS, etc. Most of what I know is based on following examples. Currently, I am working on a header menu where each link acts as an anchor within the page (the divs are hidden until clicked). However, I have encountered a problem that I can't seem to solve. Here's how my links are set up within the page:

<div class="header">
    <a href="#B1">Block 1</a>
    <a href="#B2">Block 2</a>
</div>

When clicked, this will give me a URL like "localhost/test1.html#B1". However, one of the div blocks contains the following code:

<div id="B1">
    <a href="#slide-one">
    <a href="#slide-two">
</div>

I have realized that I can't use a URL like

"localhost/test1.html#B1#slide-one"
.

I'm not sure if it's even possible to have an anchor link to a page that already has an anchor in place. I cannot utilize jQuery, flash, java, or anything other than HTML/CSS. While I assume it might not be possible, I wanted to make one last attempt and ask for help here.

EDIT: I've updated the sample code for better explanation:

 <style type="text/css">
div#Menu {
  height:90px;
  left:0;
  position:fixed;
  top:-5px;
  width:100%;
  text-align:center;
}

div#B1 {
  position:absolute;
  left:-1000px;
  margin-top:0;
}
div#B1:target {
  top:100px;
  left:375px;
}

div#B2 {
  position:absolute;
  left:-1000px;
  margin-top:0;
}
div#B2:target {
  top:100px;
  left:375px;
}
</style>
</head>

<body>
<!--Header Menu-->
<div id="Menu" class="header">
    <a href="#B1">Block 1</a>
    <a href="#B2">Block 2</a>
</div>



<div id="B1" class="blocks">
    <div id="Slider1" class="Slide">
        <ul>
            <li id="slide-one"><img src="slide-one.png"/></li>
            <li id="slide-two"><img src="slide-two.png"/></li>
        </ul>
        <a href="#slide-one">Slide 1</a>
        <a href="#slide-two">Slide 2</a>
    </div>
</div>

<div id="B2">
    <div id="Slider1" class="Slide">
        <ul>
            <li id="slide-three"><img src="slide-three.png"/></li>
            <li id="slide-four"><img src="slide-four.png"/></li>
        </ul>
        <a href="#slide-three">Slide 3</a>
        <a href="#slide-four">Slide 4</a>
    </div>
</div>

The setup includes CSS image sliders with thumbnail navigation that link to anchors within each section. When I click on Block #1 in the menu, it opens showing an image slider gallery inside it. My page URL changes to "test1.html#B1". The image slider also has anchors for each image.

In a regular situation, the slider alone would give URLs for each image like "test1.html#slide-one". But since this is nested and the image slider is a child element of the "B1" block, I need Block #1 to remain open while navigating through the images.

Answer №1

It seems like your question suggests two distinct needs:

  1. If you are trying to access

    localhost/test1.html#B1#slide-one
    , it may imply that you believe #slide-one exists not only within the "context" of #B1, but also in other locations (such as
    #B2</code): if this is the case, then <code>#B1
    and #B2 must be on separate HTML pages! In this scenario, what you desire cannot be achieved.

  2. Conversely, based on the rest of your explanation, it appears that all the elements you wish to access exist on the same page. This will be clarified in the following part of my response.

In a single HTML page, there can't be multiple instances of the same id: each id is intended to be unique by default.
Therefore, to target a specific id, you do not require several intermediary points, even if the user might have utilized these intermediaries, as mentioned in your example.

To summarize, the code provided in your query should suffice for your needs!

Lastly, while an id must always be unique, you can reference it from numerous places without limitation. Essentially, the same (unique) target can be linked from multiple <a> tags.

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

Left-aligned and centered - Bootstrap

I need help figuring out how to center a list of items on the page, but have them aligned left. I am using bootstrap. I want the text to be in the center of the page but aligned left. <ul class='text-center'> <li class=& ...

The webpage is drifting sideways to the right without any content being displayed

Recently, I launched a new website and encountered an issue with a static page I designed. While it may not be a critical problem, it is certainly bothering me! If you want to check out the website in question, visit: In essence, I have used CSS to hide ...

Discover the steps to convert an image to base64 while circumventing the restrictions of the same-origin policy

I've been struggling to convert an image link to base64 in order to store it on the client-side browser (IndexedDB). Despite searching for a solution for days, I have not been able to find one that addresses my issue. While I can successfully convert ...

The eBay API is providing users with small thumbnail images with low resolution

Adding &outputSelector=GalleryInfo to the URL was supposed to give me a higher resolution thumbnail, but it doesn't seem to be working. I'm still new to JSON and the tutorial I'm following isn't very clear on the exact syntax needed ...

Creating Shadows in Swift with Xib for TableView

I am currently working on: Attached is a screenshot from an iPhone: This is the code snippet in question: cell.shadowLayerView.layer.masksToBounds = false cell.shadowLayerView.layer.shadowOffset = CGSize(width: 0, height: 0) cell.shadowLayerView.layer.s ...

How to reference ASP.NET Core Blazor static files within a css asset

The latest enhancement in .NET 9.0 known as MapStaticAssets is designed to improve the deployment of static asset files. It addresses issues like outdated assets in browsers and allows for the delivery of compressed versions of assets. To include a static ...

Resizing Image-maps and images on the fly with maphilight.min.js

In relation to the question about dynamically resizing image-maps and images, I found a helpful solution provided by Teemu. I adapted it for my own purposes and you can view my version on jsfiddle. However, when trying to apply this solution to my project ...

Efficiently Minimize Bootstrap Components Upon Clicking the Link

I've successfully created a navigation menu that expands and collapses without using a dropdown feature. However, I'm encountering an issue where I can't seem to toggle the div when clicking on a menu link. I attempted to use JavaScript to c ...

Tips for showcasing mobile view content on a full web screen

Link to the Reference Page:- https://i.sstatic.net/fmahp.png This query has been raised by a developer before, but the provided solution did not work for me. Link to the original question:- How to Change Desktop View, Tablet View, and Mobile View Inside ...

Issue with running `npm start` in React after installing React script version 3.4.0

I'm new to React.js and I've been having trouble getting it to work after using npm start. No matter what I try, I can't seem to get it running. Any help would be appreciated. Error [email protected] start C:\xampp\htdocs& ...

Creating Hover Areas on Sprites: A Step-by-Step Guide

The goal of this code is to create two interconnected areas on the top 50px of a page that will trigger a hover effect when the mouse moves vertically. The intention is for an image to shift laterally as you hit these two hover regions. <html> <h ...

Set the value of a div's tag in HTML by assigning a variable

I have a XSLT code that displays an image in a jQuery slider. Here is the initial code... <div id="carousel-example-generic" class="carousel slide" data-ride="carousel"> <ol class="carousel-indicators"> <li data-target ...

Having trouble getting SPRITE SVG or SIMPLE SVG to show up when using xlinkHref in a React JSX file

I'm struggling to get the SVG logo to display. I created the SVG using icomoon. I'm trying to use xlinkHref="path/to/my/svg" in my jsx code, but it just won't work. Can anyone point out what I might be missing? Here's the desired effec ...

Trouble with displaying object values in a dropdown menu

I am receiving data from an array of objects, each with 3 properties: https://i.sstatic.net/Fv0qB.png This script is stored in a scope variable for use on the view. angular.forEach(result.updatedItems, function (attr) { $scop ...

What is the process for implementing document.ondrop with Firefox?

I'm experiencing an issue where the document.ondrop function seems to be working in Chrome, but not in Firefox. Here's a link to an example demonstrating the problem: In the example, if you try to drop a file onto the page, it should trigger an ...

What is the method for creating a static tooltip using CSS?

Is there a way to create a CSS tooltip similar to the one used on linkedin.com for the "share an update" textbox? I'm looking for a static tooltip that acts as a wrapper for a textbox, rather than a hover pop-up bubble tooltip. Thank you in advance. ...

How can I access the value of dynamically loaded radio buttons using jQuery?

Upon making an ajax call, I am loading this category div when the page loads. After that, I intend to trigger another ajax function based on the selected radio button value. Here is the relevant HTML code snippet: <div id="category_data"> <br> ...

Dark strips appearing on Bootstrap modal in Chrome browser on Android

When I open modals on Android's Chrome, I am seeing black "bars" as shown in the attachments. This is my code and I am using Bootstrap 4.1. Can anyone assist me with this issue? <div class="modal fade" id="modalCombos" tabindex="-100" role="dialog ...

What is the best approach for managing routing in express when working with a static website?

Whenever a user navigates to mydomain.com/game, I aim for them to view the content displayed in my public folder. This setup functions perfectly when implementing this code snippet: app.use('/game', express.static('public')) Neverthel ...

Choosing a specific HTML element by index using jQuery

Currently implementing a slick carousel slider. After utilizing the events method to retrieve slide index numbers, how can I insert specific HTML tags for that particular index? ...