I have 4 different html web pages. Below is the html code for the menu bar that I want to apply to all four pages. Is there a way to do this with CSS instead of copying / pasting this HTML text code on all 4 of my html pages? Basically, four pages are Home, News, Contacts, A. Whenever someone clicks on a menu item, he redirects them to one of 4 pages. And on all 4 of these pages, I want the menu to display. I want to create a CSS file that I can only associate with 4 pages, and then a menu will appear (code below). Thanks in advance!
Is there a way to create a CSS file that at least takes care of styling? And will I manually add menu buttons to each html page?
<!DOCTYPE html> <html> <head> <style> body { margin: 0; } ul { list-style-type: none; margin: 0; padding: 0; width: 25%; background-color: #f1f1f1; position: fixed; height: 100%; overflow: auto; } li a { display: block; color: #000; padding: 8px 0 8px 16px; text-decoration: none; } li a.active { background-color: #4CAF50; color: white; } li a:hover:not(.active) { background-color: #555; color: white; } </style> </head> <body> <ul> <li><a class="active" href="page1.html">Home</a></li> <li><a href="page2.html">News</a></li> <li><a href="page3.html">Contact</a></li> <li><a href="page4.html">About</a></li> </ul> <div style="margin-left:25%;padding:1px 16px;height:1000px;"> </div> </body> </html>
source share