Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I add a link to heading?

Tags:

html

Can I add a link to heading in HTML? Something like this

<h2 href="/ingredients">illness</h2> 

Somehow it seems to work on simple text only.

like image 839
Bick Avatar asked Apr 29 '12 20:04

Bick


People also ask

Can links be headings?

No. A heading appears before the body of the section. A menu of items linking to sections is not a collection of headings.

Can headings be links HTML?

a > h1 { ... } As has been mentioned previously, you cannot have a block level element inside an inline one (in this case a header inside a link). However, you can have an inline level element inside a block level element (a link inside a header).

What is a heading URL?

HTTP headers are the name or value pairs that are displayed in the request and response messages of message headers for Hypertext Transfer Protocol (HTTP). Usually, the header name and the value are separated by a single colon. HTTP headers are an integral part of HTTP requests and responses.

How do you add an anchor to a header?

To add an anchor to a heading in HTML, add a <section> element with an id attribute. Don't use <a name> . Use lowercase for id values, and put hyphens between words.


2 Answers

(Almost) All elements may contain other elements. So the following is possible:

<h2><a href="/ingredients">Illness</a></h2>
like image 196
Madara's Ghost Avatar answered Nov 10 '22 03:11

Madara's Ghost


you need to tag the a anchor tag inside your h2 tag. something like this:

<h2><a href="/ingredients">illness</a></h2>
like image 24
Hamza Waqas Avatar answered Nov 10 '22 03:11

Hamza Waqas