Home arrow HTML arrow Page 2 - More Convenient FAQ Web Pages
HTML

More Convenient FAQ Web Pages


A conventional Frequently Asked Questions page has questions at the top of the page. Below these questions are the answers. The questions are links. When you click a question the page jumps to the answer. We can design a better FAQ page, however. Keep reading to find out how.

Author Info:
By: Chrysanthus Forcha
Rating: 5 stars5 stars5 stars5 stars5 stars / 2
April 29, 2009
TABLE OF CONTENTS:
  1. · More Convenient FAQ Web Pages
  2. · Example
  3. · The HEAD Element
  4. · Testing with Browsers

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
More Convenient FAQ Web Pages - Example
(Page 2 of 4 )

I will use an example to explain how the above works. In this example, the color of a question is red. After clicking it becomes permanently orange. The color of the text of the answers is always brown. The example is simple; there are just three questions, each with its answer. In each answer I have used line break elements to show that you can create paragraphs in an answer (DD element) in this manner.

The Code

This is the web page without the style sheet and JavaScript:


<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>

</head>

<body>

<dl>

<dt class="faq" id="dt0" onclick="expandorCollapse('dt0')">This is the first question?</dt>

<dd class="faq" id="dd0" style="display:none">Answer to first question.<br />

Continuation of answer to first question.

</dd>

<dt class="faq" id="dt1" onclick="expandorCollapse('dt1')">This is the Second question?</dt>

<dd class="faq" id="dd1" style="display:none">Answer to second question.<br />

Continuation of answer to second question.

</dd>

<dt class="faq" id="dt2" onclick="expandorCollapse('dt2')">This is the third question?</dt>

<dd class="faq" id="dd2" style="display:none">Answer to third question.<br />

Continuation of answer to third question.

</dd>

</dl>


</body>

</html>


The first two lines and the start <html> tag are XHTML requirements. The CSS and JavaScript will be in the HEAD element.

Let us look at what is in the BODY element. The BODY element has just one DL element. This DL element has three DT elements. Each DT element has its DD element just below it. Remember, the DT element has the question, and its DD element has the corresponding answer.

Let us look at the first DT element and its DD element. The DT element belongs to a CSS class called "faq" for Frequently Asked Questions. It has an ID. It has an onclick event attribute. When clicked, the  expandorCollapse('dt0') function is called, with the ID of the DT element passed as argument. This function will display the answer, pushing the questions below downward.

The DD element for the first DT element belongs to a CSS class called "faq." Now the DD's class and the DT's class are the same; however, at the style sheet, there is separation. The DD element has the style attribute where the value of the display property is "none." This is the initial and default value. Under this condition, the DD element is not seen and does not occupy space.

The rest of the DL elements are correspondingly the same, but with different IDs.


blog comments powered by Disqus
HTML ARTICLES

- HTML5 Boilerplate: Working with jQuery and M...
- HTML5 Boilerplate Introduction
- New API Platform for HTML5
- BBC Adopts HTML 5, Mozilla Addresses Issues
- Advanced Sticky Footers in HTML and CSS
- HTML and CSS Sticky Footers
- Strategy Analytics Predicts HTML5 Phones to ...
- HTML5 Guidelines for Web Developers
- Learning HTML5 Game Programming
- More Engaging CSS3 and HTML Background Effec...
- Engaging HTML and CSS3 Background Effects
- More Web Columns with CSS3 and HTML
- Columns with CSS3 and HTML
- Creating Inline-Block HTML Elements with CSS
- Drag and Drop in HTML5: Parsing Local Files

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 9 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials