Clickable image

jarailet Posted messages 199 Registration date   Status Member Last intervention   -  
mamiemando Posted messages 33228 Registration date   Status Moderator Last intervention   -

My image AG25.jpg is inserted in a page.:
<a href="images/AG2025.php"> <img src="images/AG25.jpg"...
I would like that by clicking on it, another page AG2025.php opens,
But I'm getting lost in the tags. Help!!!
alain

3 answers

  1. yclik Posted messages 3875 Registration date   Status Member Last intervention   1 609
     

    Good evening

    While waiting for a professional, refer to the Target tag from memory.

    0
  2. mamiemando Posted messages 33228 Registration date   Status Moderator Last intervention   7 942
     

    Hello,

    If I understood your question correctly, you just need to adapt this skeleton:

    <a target="_blank" href="https://www.google.fr"> <img src="image.jpg"/> </a> 

    Explanations:

    • The img tag allows you to embed an image (the path is indicated by src). Ideally, you should avoid using more than one; all style attributes should be defined as much as possible in the site's stylesheet (css file).
    • Only the a tag allows you to create a hyperlink. Therefore, you need to nest the img tag within the a tag.
      • The href attribute indicates the target address (URL);
      • The target="_blank" attribute is optional and means the target URL should be opened in a new tab.

    Advanced explanations: Here, I wrote in XHTML, meaning "strict" HTML.

    • An XML file consists of a nesting of tags. A tag can only close when all the sub-tags it contains are closed.
    • A tag x is written starting with <x> (opening tag) and ending with </x> (closing tag), where x is a string of letters. Between these two tags, other tags, text, etc., can be inserted.
    • When a tag contains nothing, it can be written in shorthand as <x/>. This is always the case for an image (img tag).
      • You could write <img ...></img>.
      • To abbreviate, you would write <img/> instead.
      • You could write <img> but in that case, the file is no longer XML (and therefore no longer XHTML): it becomes "just" HTML.
    • The a tag must "envelope" the entire image, thus we cannot abbreviate this tag.
    • You could perfectly wrap something other than the image in this link (for example, text).

    Good luck

    0
  3. Panth33ra Posted messages 23138 Registration date   Status Member Last intervention   Ambassadeur 2 365
     

    Hello as well,

    "Neither hello, nor me"... You're not very polite.

    Polite phrases are essential on the CCM Forum when you write... https://www.commentcamarche.net/infos/25855-charte-d-utilisation-de-commentcamarche-net-respect-d-autrui/#politesse

    Thank you for adhering to this.


    -1
    1. jarailet Posted messages 199 Registration date   Status Member Last intervention   5
       

      Hello then,
      I'm sorry, I've been struggling since this morning with the layout of a file and therefore the ability to access it.. Out of patience, I called some friends for help... and in this case, panic makes you forget the usual practices. Sorry again!!!
      ... And thanks in advance! :-)

      0