Is it possible to create a drop-down menu strictly in CSS? I cannot find a site that demonstrates this.
Printable View
Is it possible to create a drop-down menu strictly in CSS? I cannot find a site that demonstrates this.
Yes it is totally possible. I have supplied a demonstration link below:
http://jsfiddle.net/ndRhj/
You have my permission to copy this code and adapt it according to your needs.
(I would suggest adding javascript to extend the functionality of the dropdown to be used by clicks/taps so that tablet users are not ill-effected. Because in its current state the dropdown relies entirely on the :hover event.)
John,
Thank you.
But is there a way to eliminate HTML?
No. CSS is used to style markup. It's a dependent language, CSS by itself won't render anything.
Where are you going with this? Why in the world would you want to eliminate the HTML?Code:But is there a way to eliminate HTML?
If the drop down menu was only integrated within CSS, I would not have to update each individual (20+pages) of code. For instance, I have a drop-down menu (js, css, html files) and when I want to make a change, I have to change each instance of the drop down menu HTML-wise.
Any advice?
You'll want to use a server side include for global content.
Ex:
menu.php would contain your global content.Code:<?php
include('menu.php');
<p>content on the rest of your page</p>
?>