Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to have the class="selected" depending on what the current page/url is
    text
    copied!<p>This is my first post so forgive as I am just new in the world of web development.</p> <p>Normally, when I try to make a website, I create a file called header.html and footer.html so that I only change data once in all of the pages rather than having multiple same headers on many html files. And include them all in a php file together with the content and the php codes that comes per page.</p> <p>Now my problem is because I only have 1 header, the css is designed in a way that whatever the current menu/tab is, it will be marked as "selected" so that its obvious to the user what page they are currently in. </p> <p>My question is how do I solve this problem:</p> <p>1.) To have the <code>class="selected"</code> depending on what the current page/url is.</p> <pre><code>&lt;!--Menu Starts--&gt; &lt;div class="menu"&gt; &lt;div id="smoothmenu" class="ddsmoothmenu"&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="index.php" class="selected"&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="about.php"&gt;About&lt;/a&gt; &lt;/li&gt; &lt;li&gt;&lt;a href="services.php"&gt;Services&lt;/a&gt; &lt;/li&gt; &lt;li&gt;&lt;a href="features.php"&gt;Features&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Support&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="support1.php"&gt;Support 1&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="support2.php"&gt;Support 2&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; &lt;!-- Menu Ends--!&gt; </code></pre> <p>Thank You :)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload