/**handles:divi-style**/
You can achieve this by utilizing the Intersection Observer API which provides a way to asynchronously observe changes in the intersection of a target element with an ancestor element or with a top-level document's viewport. It is perfect for detecting which section is currently in the viewport.  Here's a simple implementation: Enqueue the JavaScript file First,for each entry: The id of the target is retrieved. If the target is intersecting with the viewport (entry.intersectionRatio>0),it starts observing all section elements that have an id. Add the active class styling The 'active' class doesn't do anything on its own. You have to add some CSS rules to make it have an effect. In your theme's CSS,the active class is added to the corresponding menu item. If the target is not intersecting with the viewport,the active class is removed from the corresponding menu item. Finally,which will execute a callback function whenever the intersection status of an observed element changes. In the callback function,you can add something like this: css .menu-item a.active,you will need to enqueue a JavaScript file. Place the following code in your theme's functions.php:  php  function enqueue_custom_script() {     wp_enqueue_script('custom-script', get_stylesheet_directory_uri() . '/js/custom-script.js', array('jquery'), '1.0', true); }  add_action('wp_enqueue_scripts', 'enqueue_custom_script');  This code enqueues a JavaScript file named custom-script.js located in a js folder in your theme's directory. Create the JavaScript file Next{color:#red}