Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <main class="todo-list">
	<h1 class="todo-list__heading">Todo List</h1>
	<ul class="todo-list__list list">
		<li class="list__list-item"><span class="parent">Groceries</span>
			<ul class="list__sublist">
				<li class="list__list-item">3 Tomatoes</li>
				<li class="list__list-item">1 bunch of cherries</li>
				<li class="list__list-item">6 onions</li>
				<li class="list__list-item">3 heads of garlic</li>
				<li class="list__list-item">1 bag spring mix</li>
			</ul>
		</li>
		<li class="list__list-item">Cancel gym membership</li>
		<li class="list__list-item">Clean gutters</li>
		<li class="list__list-item">Take package to the post office</li>
		<li class="list__list-item">Call Avery about Ali's party (afternoon)</li>
		<li class="list__list-item">Sort recycling & put out trash</li>
	</ul>
</main>
              
            
!

CSS

              
                //    Table of Contents:
// 1. Settings
// 2. Tools
// 3. Generic
// 4. Elements
// 5. Objects
// 6. Components

// =====================================================================
// 1. Settings
// 		variable definitions

// =====================================================================
// 2. Tools
// 		mixins and functions

// =====================================================================
// 3. Generic
// 		Normalize taken care of in CodePen settings

// =====================================================================
// 4. Elements
//  	Styling for bare HTML elements (like H1, A, etc.).
body {
	font-family: "Grape Nuts", cursive;
	margin: 1rem;
}

ul,
li {
	list-style: none;
	margin-left: 0;
	padding-left: 0;
}

// =====================================================================
// 5. Objects
//    Class-based selectors which define undecorated design patterns,

.todo-list {
	max-width: 70ch;
	margin: 1rem auto;
	display: flex;
	flex-direction: column;
	align-items: center;

	li {
		margin: 0.5em 0;
		text-transform: capitalize;
	}
}

// =====================================================================
// 6. Components
//    Specific UI components. This is where majority of our work takes place
//    and our UI components are often composed of Objects and Components.

* {
	box-sizing: border-box;
}

.todo-list {
	&__heading {
		text-transform: uppercase;
		text-decoration: underline;
		text-underline-offset: 0.2em;
	}
}

.list {
	font-size: 2rem;

	&__list-item {
		line-height: 1;

		&::before {
			box-sizing: border-box;
			content: "";
			width: 1ch;
			height: 0.8em;
			margin: 0;
			margin-right: 0.5rem;
			border: 1px solid black;
			display: inline-block;
		}

		&--checked {
			&::before {
				content: "X";
			}
		}
	}
}

.list__sublist {
	padding-left: 2rem;
	.list__list-item {
	}
}

.parent {
	text-decoration: underline;
	text-decoration-thickness: 0.1rem;
	text-underline-offset: 0.1em;
}

              
            
!

JS

              
                // toggle checked list styles when list item clicked
const list = document.querySelector("ul");

list.addEventListener("click", (e) => {
	if (e.target.tagName === "LI") {
		e.target.classList.toggle("list__list-item--checked");
	}
});

              
            
!
999px

Console