Prev | Current Page 225 | Next

Craig Grannell

"The Essential Guide to CSS and HTML Web Design"


When linking to other elements on a web page, you start by providing an id value for any
element you want to be able to jump to. To link to that, you use a standard anchor element
() with an href value equal to that of your defined id value, preceded by a hash
symbol (#).
For a list of questions, you can have something like this:

Later on in the document, the first two answers might look like this:

The answer to question 1!


Back to questions


The answer to question 2!


Back to questions


As you can see, each link??™s href value is prefixed by a hash sign. When the link is clicked,
the web page jumps to the element with the relevant id value. Therefore, clicking the
Question one link, which has an href value of #answer1, jumps to the paragraph with the
id value of answer1. Clicking the Back to questions link, which has an id value of
#questions, jumps back to the list, because the unordered list element has an id of
questions.
Backward compatibility with fragment identifiers
In older websites, you may see a slightly different system for accessing content within a
web page, and this largely involves obsolete browsers such as Netscape 4 not understanding
how to deal with links that solely use the id attribute.


Pages:
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237