Page 1 of 1

[SOLVED] Where to place the "id=" when using <a href'#" to link to it (HTML5)

Posted: Sun Jun 13, 2021 6:41 pm
by paulp575
Trying to update my last HTML4.01 transitional document to HTML 5 and have a lot of <a name=" markers throughout the document.
I'm using these in case I want to point someone to that particular spot on the web page.
I get that those should be changed to "id=" which I can do, but where do I put them?
This is the page I'm trying to convert: http://dog-walker.org/trains-modern.htm.
You will see each item has the <a name=". I want them as close to the beginning of the item's description as possible.
Some of the items are contained in tables [more than one pic] so that's not a problem as I can put them in the TABLE tag, but those without a TABLE tag?

thanks

Re: Where to place the "id=" when using <a href'#" to link to it (HTML5)

Posted: Sun Jun 13, 2021 8:47 pm
by Albert Wiersch
Hello Paul,

Instead of:

Code: Select all

<a name="KRIS_MODEL_TRAINS_ITEMS"></a>
<span class="TEXT-SIZE-24PT">Kris Model Trains (KMT) Items</span>
Simply use:

Code: Select all

<span id="KRIS_MODEL_TRAINS_ITEMS" class="TEXT-SIZE-24PT">Kris Model Trains (KMT) Items</span>
Just put the "id" attribute on the element you want it to go to.

I hope this helps!

Re: Where to place the "id=" when using <a href'#" to link to it (HTML5)

Posted: Sun Jun 13, 2021 10:00 pm
by paulp575
Already replaced those types, but what about where I have no CSS or HTML tag? How do I do that? For example:

Code: Select all

<!-- K-Line Loves New York State Boxcar (K-515709) -->
<a name="K-515709"></a>
K-Line Loves New York Boxcar (K-515709)
<br>
<a href="trains/modern/K-515709.jpg" onclick="NewWindow(this.href,'name','1220','447','yes');return false;">
  <img src="trains/modern/K-515709.jpg" alt="K Line Loves New York Boxcar image" title="K Line Loves New York Boxcar" width="600" height="214">
</a>
<br><br>
Can id= stand alone without ant CSS or HTML tags?

Thanks

Re: Where to place the "id=" when using <a href'#" to link to it (HTML5)

Posted: Sun Jun 13, 2021 11:20 pm
by Albert Wiersch
paulp575 wrote: Sun Jun 13, 2021 10:00 pm Already replaced those types, but what about where I have no CSS or HTML tag? How do I do that? For example:

Code: Select all

<!-- K-Line Loves New York State Boxcar (K-515709) -->
<a name="K-515709"></a>
K-Line Loves New York Boxcar (K-515709)
<br>
<a href="trains/modern/K-515709.jpg" onclick="NewWindow(this.href,'name','1220','447','yes');return false;">
  <img src="trains/modern/K-515709.jpg" alt="K Line Loves New York Boxcar image" title="K Line Loves New York Boxcar" width="600" height="214">
</a>
<br><br>
Can id= stand alone without ant CSS or HTML tags?

Thanks
I think the best solution in this case would just be to add an appropriate tag... perhaps something like this:

Code: Select all

<span id="K-515709">K-Line Loves New York Boxcar (K-515709)</span>

Re: Where to place the "id=" when using <a href'#" to link to it (HTML5)

Posted: Tue Jun 15, 2021 6:48 pm
by paulp575
Worked - again thanks!
Unfortunately I'm scrapping updating that page to HTML 5. Way too many changes needed.
I looked for an HTML 4.01 transitional to HTML5 converter, but nothing. I did see plenty of pages that said what needed to be changed.

Re: Where to place the "id=" when using <a href'#" to link to it (HTML5)

Posted: Tue Jun 15, 2021 7:07 pm
by Albert Wiersch
paulp575 wrote: Tue Jun 15, 2021 6:48 pm Worked - again thanks!
Great! You're very welcome.
paulp575 wrote: Tue Jun 15, 2021 6:48 pm Unfortunately I'm scrapping updating that page to HTML 5. Way too many changes needed.
I can certainly understand that.
paulp575 wrote: Tue Jun 15, 2021 6:48 pm I looked for an HTML 4.01 transitional to HTML5 converter, but nothing. I did see plenty of pages that said what needed to be changed.
I am not familiar with any except perhaps HTML Tidy which you could try. I haven't used it for conversion though, or for much else because I have little or no need to use it... but it's there and may be able to help if you want to try.

I would bet that there are a lot of issues that make automatic conversion problematic. If your HTML4 pages work well enough and you don't have time to upgrade them to HTML5 then it's probably best to just leave it as is and just make future pages HTML5.

Re: Where to place the "id=" when using <a href'#" to link to it (HTML5)

Posted: Tue Jun 15, 2021 8:55 pm
by paulp575
I did convert most of my web pages to HTML 5, but this last page is just too long.
I may attempt some day in the future.
Problem I ran across - and am investigating is using iframe to include the menu on the top of the page and the footer.

Re: Where to place the "id=" when using <a href'#" to link to it (HTML5)

Posted: Sat Jun 19, 2021 12:13 am
by paulp575
Decided to slowly work on updating this page to HTML 5, but need help with:

Can the id="(text here)" be used twice in the same line - for example, I have this (they are on two lines):

Code: Select all

<span id="LIONEL_75TH_ANNIVERSARY_SPECIAL" class="TEXT-BOLD TEXT-SIZE-16PT">Lionel 75th Anniversary Special Set (6-1585)</span>
<span id="6-1585_SPECIFIC_ITEMS"></span>

Re: Where to place the "id=" when using <a href'#" to link to it (HTML5)

Posted: Sat Jun 19, 2021 1:00 am
by Albert Wiersch
Hello,

That shouldn't be a problem as long as the ID values are unique (you can't use the same ID twice).

You could also do this:

Code: Select all

<span id="6-1585_SPECIFIC_ITEMS"><span id="LIONEL_75TH_ANNIVERSARY_SPECIAL" class="TEXT-BOLD TEXT-SIZE-16PT">Lionel 75th Anniversary Special Set (6-1585)</span></span>

Re: Where to place the "id=" when using <a href'#" to link to it (HTML5)

Posted: Sat Jun 19, 2021 11:30 am
by paulp575
Okay - so I can place a span tag inside a span? Great! That will solve several message HTML validator keeps displaying.

Re: Where to place the "id=" when using <a href'#" to link to it (HTML5)

Posted: Sat Jun 19, 2021 12:09 pm
by Albert Wiersch
paulp575 wrote: Sat Jun 19, 2021 11:30 am Okay - so I can place a span tag inside a span? Great! That will solve several message HTML validator keeps displaying.
Yep! :D :)