How can I wrap HTML list in some div? On my drupal 8 website I have created a view, with list of content. As an output format I have chosen HTML list. So currently it looks like following: 

 &lt;form id="views-form"&gt;
   &lt;div&gt;&lt;/div&gt;
   &lt;div class="item-list"&gt;&lt;/div&gt;
   &lt;div class="item-list"&gt;&lt;/div&gt;
   &lt;div class="item-list"&gt;&lt;/div&gt;
   &lt;div class="item-list"&gt;&lt;/div&gt;
   &lt;div class="item-list"&gt;&lt;/div&gt;
    ....
   &lt;div&gt;&lt;/div&gt;
&lt;/form&gt;


For formatting I would need to wrap the html list in some other div, is there a way to do it ? Can not find anything in the interface. 

Expected: 

&lt;form id="views-form"&gt;
   &lt;div&gt;&lt;/div&gt;
   &lt;div class="html_list"&gt;
     &lt;div class="item-list"&gt;&lt;/div&gt;
     &lt;div class="item-list"&gt;&lt;/div&gt;
     &lt;div class="item-list"&gt;&lt;/div&gt;
     &lt;div class="item-list"&gt;&lt;/div&gt;
     &lt;div class="item-list"&gt;&lt;/div&gt;
   &lt;/div&gt; 
   ....
   &lt;div&gt;&lt;/div&gt;
&lt;/form&gt;
Another approach would be template files.

The template name depends on the entity you are theming.

For example, with views-view-list.html.twig:

change

&lt;{{ list.type }}{{ list.attributes }}&gt;

  {% for row in rows %}
    &lt;li{{ row.attributes }}&gt;
      {{- row.content -}}
    &lt;/li&gt;
  {% endfor %}

&lt;/{{ list.type }}&gt;


to

&lt;div class="html_list"&gt;
  &lt;{{ list.type }}{{ list.attributes }}&gt;

    {% for row in rows %}
      &lt;li{{ row.attributes }}&gt;
        {{- row.content -}}
      &lt;/li&gt;
    {% endfor %}

  &lt;/{{ list.type }}&gt;
 &lt;/div&gt;


If you go the template route, it can be general so that any view of that type will inherit your custom markup. Or, it can be specific to that view name or ID.



If you want to utilize jQuery, I would recommend being more specific with your class selectors and allow for multiple view instances. For example:

$('.views-class ul').each(function() {
  if ($(this).hasClass('item-list')) {
    $(this).wrap("&lt;div class='html_list'&gt;&lt;/div&gt;");
  }
});




Here is an example views-view.html.twig, which is one level up really from the above template... which prints the views name as a class... which allows view by view customization to structure and layout by CSS alone:

views-view.html.twig

{%
  set classes = [
    dom_id ? 'js-view-dom-id-' ~ dom_id,
    'views-wrapper',
    'view-' ~ css_name,
  ]
%}

&lt;div {{ attributes.addClass(classes) }}&gt;

  {{ title_prefix }}
  {{ title }}
  {{ title_suffix }}

  {% if header %}
    &lt;header&gt;
      {{ header }}
    &lt;/header&gt;
  {% endif %}

  {{ exposed }}

  {% if attachment_before %}
    &lt;div class="views-attachment views-attachment-before"&gt;
      {{ attachment_before }}
    &lt;/div&gt;
  {% endif %}

  {% if rows.header %}
    &lt;div class="views-header-wrapper"&gt;
      {{ rows.header }}
    &lt;/div&gt;
  {% endif %}

  {# add custom wrapper here around rows, or in deeper template files. #}
  {{ rows | without('header') }}

  {{ empty }}

  {% if pager %}
    &lt;div class="views-pager"&gt;
      {{ pager }}
    &lt;/div&gt;
  {% endif %}

  {% if attachment_after %}
    &lt;div class="views-attachment views-attachment-after"&gt;
      {{ attachment_after }}
    &lt;/div&gt;
  {% endif %}

  {% if more %}
    &lt;div class="views-more"&gt;
      {{ more }}
    &lt;/div&gt;
  {% endif %}

  {% if footer %}
    &lt;footer&gt;
      {{ footer }}
    &lt;/footer&gt;
  {% endif %}

  {{ feed_icons }}

&lt;/div&gt;


Plus, this template separates the header and exposed filters making custom templating and individual CSS easier to implement and maintain.

I add this answer because I believe Drupal theming layer should be utilized when possible before jQuery and other front-end technologies.