- 3 Ways to Highlight Links to the Current Page with CSS
- The first way – HTML/CSS
- Пример:
- 2 ways on Java Script / CSS
- Как убрать подчёркивание ссылок
- Убираем подчёркивание ссылок в CSS
- Убираем подчёркивание ссылок в HTML
- Когда убирать подчёркивание
- Материалы по теме
- How to Remove Underline from a Link in CSS – HTML Style Guide
- How to Remove Underline from a Link in CSS
- Conclusion
- How to create a link with no underline in HTML
- Make all links not underlined
- Make an individual link not have an underline
- Related information
3 Ways to Highlight Links to the Current Page with CSS
We suggest looking at 3 different ways to highlight links to the current page using CSS.
The first way – HTML/CSS
I noticed that WordPress automatically adds a class for the active clicked link. You can see this if you open the source code of the site.
In the source code you can see that the class “current-menu-item” has been added to the active link. This means that we can add any style to this class.
Пример:
Open the CSS file of the template and enter this code:
#menu li .current-menu-item a
color:#сс0000;
>
Note: This code will work if your menu has been taken in a block like mine:
id="menu">your menu (I displayed the menu via a widget)
I will now share how to highlight an active link for absolutely any site using just a little JavaScript and CSS code.
2 ways on Java Script / CSS
I want to offer you ready-made code in JavaScript, which will automatically prescribe the class ” act” to the active menu link that links to the current page. This code is easily embedded in any design, template and any CMS (Joomla, WordPress, etc.).
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> body a a:hover a.act
Link1 Link2 try < var el=document.getElementById('msgText').getElementsByTagName('a'); var url=document.location.href; for(var i=0;i;> ;> catch(e)<>