Click here to Skip to main content
15,881,173 members
Articles / Web Development / CSS3
Tip/Trick

A suggestion for CodeProject TOC Style Fix

Rate me:
Please Sign up or sign in to vote.
5.00/5 (8 votes)
7 Jul 2017CPOL1 min read 12.7K   2   7
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)


Written By
Architect
United States United States
Physics, physical and quantum optics, mathematics, computer science, control systems for manufacturing, diagnostics, testing, and research, theory of music, musical instruments… Contact me: https://www.SAKryukov.org

Comments and Discussions

 
QuestionThere's a reason for bullets Pin
Chris Maunder5-Jul-17 5:17
cofounderChris Maunder5-Jul-17 5:17 
AnswerRe: There's a reason for bullets Pin
Sergey Alexandrovich Kryukov5-Jul-17 20:15
mvaSergey Alexandrovich Kryukov5-Jul-17 20:15 
GeneralRe: There's a reason for bullets Pin
Chris Maunder6-Jul-17 3:59
cofounderChris Maunder6-Jul-17 3:59 
GeneralRe: There's a reason for bullets Pin
Sergey Alexandrovich Kryukov6-Jul-17 8:07
mvaSergey Alexandrovich Kryukov6-Jul-17 8:07 
AnswerSimple summary to this discussion Pin
Sergey Alexandrovich Kryukov8-Jul-17 7:53
mvaSergey Alexandrovich Kryukov8-Jul-17 7:53 
Praiseyes please Pin
Chris8752-Jul-17 23:09
professionalChris8752-Jul-17 23:09 
GeneralRe: yes please Pin
Sergey Alexandrovich Kryukov3-Jul-17 4:20
mvaSergey Alexandrovich Kryukov3-Jul-17 4:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.