Are all elements still displaying the menuBar style? Using the PHP include function, <?php include... ?>

Here is the Menu Bar code I am using:

<!DOCTYPE html>
<html>
<link href = menuBarStyle.css rel = "stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">   
<div class = "menu">

<ul class = "bar">
    <li><a href = "index.php">Home</a></li>
    <li><a>Music</a>
        <ul>
        <li><a href = "djdizzstart.php">DJ Dizz Home</a></li>
        <li><a href = "djdizzspotify.php">Spotify</a></li>
        <li><a href = "djdizzsoundcloud.php">SoundCloud</a></li>
        <li><a href = "djdizzitunes.php">iTunes</a></li>               
        </ul>           
    </li>            
    <li><a>Learn</a>     
        <ul>          
        <li><a>JavaScript</a></li>
        <li><a>Java</a></li>
        <li><a>Web</a></li>
        <li><a>SQL Databases</a></li>            
        </ul>
    </li>
    <li><a>Credits</a>
        <ul>
            <li><a>Design & Code</a></li>
            <li><a>Music</a></li>
            <li><a>Marketing</a></li>
            <li><a>Hosting</a></li>
           </ul>
      </li>
    <li><a id = "login">Login</a></li>
 </ul>
 </div>
</html>

This is the corresponding style:

import url('https://fonts.googleapis.com/css? 
family=Amatic+SC:700|Hind+Siliguri|Shadows+Into+Light');

body {
    background-size: cover;
    font-family: 'Hind Siliguri', sans-serif;
    color: white;
    min-width:800px;       
    width: auto !important;  
    width:800px; 
}
ul {
    margin: 0px;
    padding: 0px;
    list-style: none;    
    position: relative;
    float:left;
    left: 50%;
    cursor:pointer;
    max-width: 100%;
}
ul li {
    float: left;
    width: 200px;
    height: 40px;
    background-color: black;
    opacity: .8;
    line-height: 40px;
    text-align: center;
    font-size: 20px;
    display:block;
    position: relative;
    right: 50%;
}
ul li a {
    text-decoration: none;
    color: white;
    display: block;       
}
ul li a:hover {
    background-color: green;
}
ul li ul li {
    display: none;
}
ul li: hover ul li {
    display: block;
}
#login {
    background-color: green;
    text-decoration: none;
    border: none;
}
#login:hover {
    background-color: limegreen;
}
#menu {
    z-index: 2;
    position: relative;
}

I am trying to make other elements independent from this style but the ul li in my other code always inherits the styling from my Navigation bar.

<!DOCTYPE html>
<html>    
<head><title>DJ Dizz iTunes</title></head>
<?php include ("menuBar.html"); ?>
<link href = "style.css" rel = stylesheet>
<body>
    <div id="Startpage">
        <p style="text-align: center">iTunes</p>
    </div>
    <div id="itunes" style="text-align:center">
        <a href="https://geo.itunes.apple.com/us/artist/dj-dizz/1204428323?mt=1&app=music" style="display:inline-block;overflow:hidden;background:url(https://linkmaker.itunes.apple.com/assets/shared/badges/de-de/music-lrg.svg) no-repeat;width:200px;height:55px;"></a>
    </div>
    <ul id="songs">
        <li><a href = "https://geo.itunes.apple.com/us/album/staying-down/1434126188?i=1434126382&mt=1&app=music">Staying Down</a></li>
        <li><a href = "https://geo.itunes.apple.com/us/album/its-me/1270058662?i=1270058790&mt=1&app=music">It's Me</a></li>    
    </ul>           
</body>
</html>

The other ul li elements with iTunes href's are not changing at all and they retain the styling of the Navigation bar even after trying to assign classes and ids. All files are in PHP format except for the Navigation bar which is an HTML file.

Feedback and suggestions would be greatly appreciated.

Lars (Beginner)

Answer №1

Make sure to include the "bar" class in your CSS rules when styling your navigation with a class of "bar". By doing so, you can target only that specific element and not all ul elements on the page. Here's an example:


ul.bar {
margin: 0px;
padding: 0px;
... etc ...
}

ul.bar li {
float: left;
width: 200px;
... etc ...
}

Apply this approach to all your ul rules in your CSS for proper formatting.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Show content when box is ticked

I am looking to display a row of text when a checkbox is checked, but I am finding it challenging as a beginner in this. Despite trying to understand other answers, I still struggle with the process. Here is what I have attempted so far: function RiskPl ...

"Encountering a Javascript issue while trying to apply a CSS class to a

Encountering issues in Safari desktop / mobile and Internet Explorer. The error message states: In Safari: TypeError: Attempted to assign to readonly property. IE Edge: Assignment to read-only properties is not allowed in strict mode The problem arises ...

Issue with Bootstrap 4 navigation tabs: dropdown items do not cycle through active tab panels

Whenever I utilize nav-tabs to toggle between tabpanels, it functions properly. However, there seems to be an issue when attempting to switch the active tabpanel using the links in the dropdown menu. Below is the HTML for my nav-tabs and dropdown menu, alo ...

I am experiencing an issue with using double quotation marks in VS Code

Whenever I press the double quote symbol like this "", the cursor automatically moves to the end. While this may be natural, I would prefer the cursor to move inside the double quotes automatically when pressing them. Additionally, it's a bi ...

Customizing Your WooCommerce Storefront: Tips for Enhancing Your Product Catalog and Minimizing White Space

Lately, I've been working on enabling a product filter in the left sidebar of my Woocommerce theme. However, I have noticed that the layout is not quite how I would like it to be. Take a look at this image that shows the changes I am aiming for. Cur ...

Blazor components experience element interaction while utilizing more than one instance of Blazorise.Bootstrap component

I am facing an issue in my Blazor app where a component with a button and bootstrap collapse works fine when used once on a page, but triggers collapse elements in other instances when used multiple times. This seems to be happening because their IDs are s ...

Printing a React component using a button causes formatting related to className to be lost, while printing it inline preserves the formatting

I've hit a roadblock in trying to figure out the React and printing issue for the past week and a half, and it feels like I'm going in circles. Despite finding some helpful solutions on Stack Overflow, none of them seem to work completely for me ...

Displaying MongoIds in HTML output for the user

Currently, I am in the process of developing a web application that utilizes MongoDB as its database management system. One challenge I am facing is finding a way to accurately identify which object the user has selected from a list on the screen, and the ...

In my development environment, the page does not have scroll functionality, but in the production environment, it is scrollable

Whenever I open a table or any other element with overflowing content, I encounter an issue with the scrolling bar. Even though the CSS includes overflow-y: scroll;, the scroll bar on the right remains in gray and does not allow me to scroll down when the ...

Using CSS to overlay a background image on top of a background gradient

Struggling to get both a background gradient and a background image (transparent PNG) to display in my div. No matter what, only the color gradient shows up while the image remains hidden. If I use a solid color instead of a gradient, the image displays ju ...

Showing a notification that is persistent and not dismissible

Hello everyone! I've been struggling with a problem on the RPS project for quite some time now. The issue arises when I try to display a message for a tie in the game, but I can't seem to find a solution to make it disappear when the round is not ...

Ways to initiate a flip motion

Looking for a way to create a flip image effect when clicked by the user. Here is the code I have so far: let img = document.querySelector('img') let div; let click = 0; img.onclick=function(){ console.log(click) if(click %2 ==0){ d ...

Importing a 3D Model Using Three.js

I've been trying to import a 3D model by following tutorials. I managed to successfully import using A-Frame Tags, but encountering issues with Three.js. The code snippets are from a tutorial on YouTube that I referred to: https://www.youtube.com/watc ...

The picture is not visible outside the parent container - why is it hidden?

Currently, I am working on project cards and using materialize css's image card to style them. One of the features that I particularly like is how it resizes the picture when included inside a container. This allows me to set a fixed height without wo ...

Undo a CSS transition when clicked

There is a div named learn-more which expands to fill the whole page when a CSS class is added like this: .learn-more{ padding:10px; font-size: 20px; text-align: center; margin-top:20px; font-family: klight; -webkit-transition:2s; ...

"When trying to access a jQuery ID, it is coming back as undefined even though the

I'm attempting to obtain the ID of a specific element, save it as a variable, and then utilize that ID value to interact with other elements in the same section bearing the identical ID. <div class="mainContent"> <div class="articleContent"& ...

Mastering @media queries to dynamically alter widths in prop styled components

I have a unique component that utilizes an object with its props for styling. const CustomSection = ({ sectionDescription, }) => { return ( <Text {...sectionDescription} content={intl.formatMessage({ id: &apos ...

Extracting Data from Input Box Using Query

In my HTML setup, I have five <textarea> tags with IDs text1,text2,text3,text4, and one additional <textarea> tag with ID output. I want to query based on the values of text1,text2,text3,text4 (referred to as field1, field2, field3, field4). F ...

Creating an email in Gmail with a pre-filled HTML body

Currently, I am developing a Django web application and seeking a way to enable my app to send emails via Gmail. I have explored creating a hyperlink that opens the compose window in Gmail, as well as prepopulating fields such as "to," "cc," "bcc," and bod ...

Resizable vector graphics with consistent border dimensions

I need a solution that maintains a constant line width while still making the SVG responsive. Here is the desired outcome: https://codepen.io/dudleystorey/pen/wMLBLK The example linked above achieves this using CSS, but I am looking to achieve the same r ...