Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / web / CSS3

A suggestion for CodeProject TOC Style Fix

5.00/5 (8 votes)
7 Jul 2017CPOL1 min read 13.4K  
An ugly look of a TOC based on ul elements is the only problem preventing full automation of article writing; still, it's easy to fix

Having trouble writing or posting articles? These articles aim to gather together tips and tricks from authors and mentors to help you write great articles.

The Suggestion

Recently, I published an article with my new article-writing toolchain: All in One Toolchain for Article Writing with Visual Studio Code.

After the files are uploaded and source code ZIP files are referenced, there is only one step needed to write the entire body of the article: paste HTML code pre-created offline. This is a very convenient and reliable thing, now made available to all CodeProject authors.

More, exactly, this is so with one exclusion: I have only one fix to do manually: TOC styles. I cannot automate it, because it is prevented by CodeProject style.

Let’s consider this code sample:

Same thing without div (see below):

In first code sample, TOC is included in the div with the class=\"toc\". It fixes the problem of unwanted bullets in the CodeProject article TOC. The CSS implementation is simple:

CSS
div.toc ul { list-style-type: none; margin-top: 0; margin-bottom: 0; }

This CSS covers all levels of heading.

The solution isolates all other occurrences of ul; the fix is applied only to the TOC structure marked by that specialized div. The idea is simple: the author is encouraged to mark TOC by placing it inside div element with the class="toc". That’s all.

It solves another problem: current CodeProject style adds margins to the inner-level ul, which created the ugly look. Here is one example of an article:

Example of an article with poor TOC formatting.

Sample Heading

Sample Heading 2

Sample Heading 3

Sample Heading 4
Sample Heading 5

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)