Sometimes developers need to add custom classes to li tag of nav menu. There are multiple ways  to this, but here we are going to show one method out of various once. Firstly, go to the functions.php and the below code there.

function text_domain_custom_nav_classes($classes, $item){
    $classes[] = "custom-css-class";
    return $classes;
add_filter('nav_menu_css_class' , 'text_domain_custom_nav_classes' , 10 , 2);

Similarly, If you want to add any type of attribute in to Anchor tag of Li, then use this code.

function text_domain_add_menu_link_attributes($atts, $item, $args)
    $atts['class'] = 'custom-css-class-nav-link';
    return $atts;
add_filter('nav_menu_link_attributes', 'text_domain_add_menu_link_attributes', 1, 3);