Can href be an ID?












3














I'm learning about JavaScript from an udemy tutorial and I try to make API calls. There is a website about recipes and I make API calls. And I have a misunderstanding because until now I knew that an href is a link, not a number.



This is a piece of code from index.html and the href is an id:



<li>
<a class="results__link results__link--active" href="#23456">
<figure class="results__fig">
<img src="img/test-1.jpg" alt="Test">
</figure>
<div class="results__data">
<h4 class="results__name">Pasta with Tomato ...</h4>
<p class="results__author">The Pioneer Woman</p>
</div>
</a>
</li>


And this is a recipe list that I receive if I make an API call and I need to put the recipe_id which is a number in the href. And I don't understand how can I put a number in the href



enter image description here










share|improve this question
























  • You can use a number as a component of the url as either a folder, file or query parameter, so long as the server understands it.
    – Patrick Sturm
    Nov 23 '18 at 10:19










  • Generally a href is a link to a page. But a hrefcan also be can idor the combination of both, so your browser automatically scrolls to the specific id
    – DestinatioN
    Nov 23 '18 at 10:20
















3














I'm learning about JavaScript from an udemy tutorial and I try to make API calls. There is a website about recipes and I make API calls. And I have a misunderstanding because until now I knew that an href is a link, not a number.



This is a piece of code from index.html and the href is an id:



<li>
<a class="results__link results__link--active" href="#23456">
<figure class="results__fig">
<img src="img/test-1.jpg" alt="Test">
</figure>
<div class="results__data">
<h4 class="results__name">Pasta with Tomato ...</h4>
<p class="results__author">The Pioneer Woman</p>
</div>
</a>
</li>


And this is a recipe list that I receive if I make an API call and I need to put the recipe_id which is a number in the href. And I don't understand how can I put a number in the href



enter image description here










share|improve this question
























  • You can use a number as a component of the url as either a folder, file or query parameter, so long as the server understands it.
    – Patrick Sturm
    Nov 23 '18 at 10:19










  • Generally a href is a link to a page. But a hrefcan also be can idor the combination of both, so your browser automatically scrolls to the specific id
    – DestinatioN
    Nov 23 '18 at 10:20














3












3








3


0





I'm learning about JavaScript from an udemy tutorial and I try to make API calls. There is a website about recipes and I make API calls. And I have a misunderstanding because until now I knew that an href is a link, not a number.



This is a piece of code from index.html and the href is an id:



<li>
<a class="results__link results__link--active" href="#23456">
<figure class="results__fig">
<img src="img/test-1.jpg" alt="Test">
</figure>
<div class="results__data">
<h4 class="results__name">Pasta with Tomato ...</h4>
<p class="results__author">The Pioneer Woman</p>
</div>
</a>
</li>


And this is a recipe list that I receive if I make an API call and I need to put the recipe_id which is a number in the href. And I don't understand how can I put a number in the href



enter image description here










share|improve this question















I'm learning about JavaScript from an udemy tutorial and I try to make API calls. There is a website about recipes and I make API calls. And I have a misunderstanding because until now I knew that an href is a link, not a number.



This is a piece of code from index.html and the href is an id:



<li>
<a class="results__link results__link--active" href="#23456">
<figure class="results__fig">
<img src="img/test-1.jpg" alt="Test">
</figure>
<div class="results__data">
<h4 class="results__name">Pasta with Tomato ...</h4>
<p class="results__author">The Pioneer Woman</p>
</div>
</a>
</li>


And this is a recipe list that I receive if I make an API call and I need to put the recipe_id which is a number in the href. And I don't understand how can I put a number in the href



enter image description here







javascript html href






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 10:49









Elina Salamon

186




186










asked Nov 23 '18 at 10:15









gaby

2668




2668












  • You can use a number as a component of the url as either a folder, file or query parameter, so long as the server understands it.
    – Patrick Sturm
    Nov 23 '18 at 10:19










  • Generally a href is a link to a page. But a hrefcan also be can idor the combination of both, so your browser automatically scrolls to the specific id
    – DestinatioN
    Nov 23 '18 at 10:20


















  • You can use a number as a component of the url as either a folder, file or query parameter, so long as the server understands it.
    – Patrick Sturm
    Nov 23 '18 at 10:19










  • Generally a href is a link to a page. But a hrefcan also be can idor the combination of both, so your browser automatically scrolls to the specific id
    – DestinatioN
    Nov 23 '18 at 10:20
















You can use a number as a component of the url as either a folder, file or query parameter, so long as the server understands it.
– Patrick Sturm
Nov 23 '18 at 10:19




You can use a number as a component of the url as either a folder, file or query parameter, so long as the server understands it.
– Patrick Sturm
Nov 23 '18 at 10:19












Generally a href is a link to a page. But a hrefcan also be can idor the combination of both, so your browser automatically scrolls to the specific id
– DestinatioN
Nov 23 '18 at 10:20




Generally a href is a link to a page. But a hrefcan also be can idor the combination of both, so your browser automatically scrolls to the specific id
– DestinatioN
Nov 23 '18 at 10:20












3 Answers
3






active

oldest

votes


















3














Yes. If the href is a # flowed by an element id it is what is called an anchor link. It will get you to the element with the given id in the same page. You can read more about it here.






share|improve this answer





























    1















    Can a href be an ID?




    In short, Yes.



    href doesn't necessarily always mean an external link, it could link to an element on the current html page, which from the example you have provided i think this is the case.



    If you map your recipe_id as a id to an element in your page, and you then say reference the recipe_id as a href when you click your href the page should scroll / navigate to the element with that id.






    share|improve this answer































      0














      You can use a number as a hyperlink, in this case anyway.



      The # means it is referring to an element with that id on the page. To my knowledge it is only classes that you cannot use a number at the beginning without escaping it.



      You are also able to leave the current page and go to an element on a different page. You can do this by tailing your #id on to the url string you are used to seeing.



      If you give more background into the project we might be able to give less vague answers.






      share|improve this answer





















        Your Answer






        StackExchange.ifUsing("editor", function () {
        StackExchange.using("externalEditor", function () {
        StackExchange.using("snippets", function () {
        StackExchange.snippets.init();
        });
        });
        }, "code-snippets");

        StackExchange.ready(function() {
        var channelOptions = {
        tags: "".split(" "),
        id: "1"
        };
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function() {
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled) {
        StackExchange.using("snippets", function() {
        createEditor();
        });
        }
        else {
        createEditor();
        }
        });

        function createEditor() {
        StackExchange.prepareEditor({
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        imageUploader: {
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        },
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        });


        }
        });














        draft saved

        draft discarded


















        StackExchange.ready(
        function () {
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53444714%2fcan-href-be-an-id%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        3














        Yes. If the href is a # flowed by an element id it is what is called an anchor link. It will get you to the element with the given id in the same page. You can read more about it here.






        share|improve this answer


























          3














          Yes. If the href is a # flowed by an element id it is what is called an anchor link. It will get you to the element with the given id in the same page. You can read more about it here.






          share|improve this answer
























            3












            3








            3






            Yes. If the href is a # flowed by an element id it is what is called an anchor link. It will get you to the element with the given id in the same page. You can read more about it here.






            share|improve this answer












            Yes. If the href is a # flowed by an element id it is what is called an anchor link. It will get you to the element with the given id in the same page. You can read more about it here.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 23 '18 at 10:20









            nikos fotiadis

            6191514




            6191514

























                1















                Can a href be an ID?




                In short, Yes.



                href doesn't necessarily always mean an external link, it could link to an element on the current html page, which from the example you have provided i think this is the case.



                If you map your recipe_id as a id to an element in your page, and you then say reference the recipe_id as a href when you click your href the page should scroll / navigate to the element with that id.






                share|improve this answer




























                  1















                  Can a href be an ID?




                  In short, Yes.



                  href doesn't necessarily always mean an external link, it could link to an element on the current html page, which from the example you have provided i think this is the case.



                  If you map your recipe_id as a id to an element in your page, and you then say reference the recipe_id as a href when you click your href the page should scroll / navigate to the element with that id.






                  share|improve this answer


























                    1












                    1








                    1







                    Can a href be an ID?




                    In short, Yes.



                    href doesn't necessarily always mean an external link, it could link to an element on the current html page, which from the example you have provided i think this is the case.



                    If you map your recipe_id as a id to an element in your page, and you then say reference the recipe_id as a href when you click your href the page should scroll / navigate to the element with that id.






                    share|improve this answer















                    Can a href be an ID?




                    In short, Yes.



                    href doesn't necessarily always mean an external link, it could link to an element on the current html page, which from the example you have provided i think this is the case.



                    If you map your recipe_id as a id to an element in your page, and you then say reference the recipe_id as a href when you click your href the page should scroll / navigate to the element with that id.







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Nov 27 '18 at 11:35

























                    answered Nov 23 '18 at 10:21









                    Luke Walker

                    27514




                    27514























                        0














                        You can use a number as a hyperlink, in this case anyway.



                        The # means it is referring to an element with that id on the page. To my knowledge it is only classes that you cannot use a number at the beginning without escaping it.



                        You are also able to leave the current page and go to an element on a different page. You can do this by tailing your #id on to the url string you are used to seeing.



                        If you give more background into the project we might be able to give less vague answers.






                        share|improve this answer


























                          0














                          You can use a number as a hyperlink, in this case anyway.



                          The # means it is referring to an element with that id on the page. To my knowledge it is only classes that you cannot use a number at the beginning without escaping it.



                          You are also able to leave the current page and go to an element on a different page. You can do this by tailing your #id on to the url string you are used to seeing.



                          If you give more background into the project we might be able to give less vague answers.






                          share|improve this answer
























                            0












                            0








                            0






                            You can use a number as a hyperlink, in this case anyway.



                            The # means it is referring to an element with that id on the page. To my knowledge it is only classes that you cannot use a number at the beginning without escaping it.



                            You are also able to leave the current page and go to an element on a different page. You can do this by tailing your #id on to the url string you are used to seeing.



                            If you give more background into the project we might be able to give less vague answers.






                            share|improve this answer












                            You can use a number as a hyperlink, in this case anyway.



                            The # means it is referring to an element with that id on the page. To my knowledge it is only classes that you cannot use a number at the beginning without escaping it.



                            You are also able to leave the current page and go to an element on a different page. You can do this by tailing your #id on to the url string you are used to seeing.



                            If you give more background into the project we might be able to give less vague answers.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Nov 23 '18 at 10:32









                            Jason Is My Name

                            419




                            419






























                                draft saved

                                draft discarded




















































                                Thanks for contributing an answer to Stack Overflow!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid



                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.


                                To learn more, see our tips on writing great answers.





                                Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                Please pay close attention to the following guidance:


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid



                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.


                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function () {
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53444714%2fcan-href-be-an-id%23new-answer', 'question_page');
                                }
                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                Catalogne

                                Violoncelliste

                                Héron pourpré