Skip to main content
Main Content

[WIP/DO NOT POST] ◆ 202's New CSS Guide

[WIP/DO NOT POST] ◆ 202's New CSS Guide
Posted 2021-11-27 13:44:07 (edited)
You might have previously known me as "Tetra" from this guide. Instead of updating that thread, I've chosen to make a new one spanning more posts [due to the new character limit] and containing more information suited to the new way we integrate code into our profiles. It is currently a work in progress.


INTRO

If you're a total beginner to webcode, you may be scratching your head as to what CSS and HTML actually is.

HTML (Hypertext Markup Language) is the fundamental language of most websites you see. Using HTML, one can divide a page into sections, create headers and links, conjure tables, and more. This is not the main concern of our guide, however; while HTML serves as the barebones construction of a page, this alone cannot make a page look appealing to the visitor. This is where CSS comes in.

CSS (Cascading Style Sheets) acts as the furnishing and coat of paint for the otherwise bare house that HTML builds. Fancy metaphor aside, one can use CSS to visually customize the HTML of a page by manipulating properties such as font, color, borders, spacing, and even more.

Wolvden's code includes a native CSS that applies to all pages, giving each page the same characteristic centered-content-over-background layout. When you navigate to some user's Dens or Profiles, however, you may notice that this layout changes drastically. This is because the user applied a custom CSS. A custom CSS file overwrites Wolvden's native CSS with new code, personalizing their Den or Profile's visual styling to their liking.

The aim of this guide is to show you how to personalize your own Den or Profile to your liking. You will be writing and uploading a CSS file to accomplish this, and this guide will show you how, from start to finish.

CSS is a professional-level language that will take a lot to write about; this guide will be text-heavy, be warned! I do suggest you give this guide a light skim first before doing anything, so you have a good understanding of what you're facing before you really dive in. Then read it thoroughly the next time, perhaps alongside writing your first CSS.

PREPARE YOURSELF

In order to apply CSS design to a page, you need a .css file. In order to obtain a .css file, not only do you need to write one yourself (which you will learn to do in this guide, hang tight!), you will also need a program that can export text into .css format.

Fear not; on Windows your default Notepad will do this nicely (TextEdit for Mac users). If needed, you may also download a third-party text/code editor such as Sublime or Notepad++. Later near the end of this guide, we will go over how to export a .css for our use – just make sure you have access to a compatible text editor for now.

It is worth mentioning this is a desktop-oriented tutorial; you may have a difficult time coding on mobile for several UI-related reasons. Regardless, if mobile is your limit, some apps can assist with mobile coding. Please note that I do not regularly use these apps and I cannot help with any app-specific troubleshooting on that end.

TRY STYLUS

You may type directly into your chosen basic text editor as you go along with the guide. But if you're starting out and just trying to learn, this kind of "blind" coding without live results or error detection could lead to a lot of otherwise avoidable frustration. For this reason, I highly suggest using Stylus to help yourself.

Stylus is a browser extension that allows you to overlay additional personal CSS styles onto each page you visit, and to toggle those styles on or off at will. It features an in-browser popup editor with versatile features such as editor themes, color pickers, autocomplete, error detection, and most importantly, instantaneous live updates. After hitting "Save" on your writing, every subsequent change you make will affect the page accordingly.

This kind of instant bit-by-bit feedback is crucial for ease of learning, and much better than writing everything out at once and having it all break for some yet-unknown reason, trying to comb through your essay of a code to diagnose your issue. It may look scary at first, but I implore starters to at least have a taste of Stylus before moving on to writing their first layout!

Once Stylus is installed, you can click on the "{S}" logo in your browser toolbar to summon a small box. From here you can manage any styles of yours that are active on this site. Create a new style for Wolvden simply by clicking on the "wolvden.com" part of the URL written under "Write style for:"



A new window or tab will appear, containing the CSS editor and your controls:



The diagram above should point out the essentials of your interface. (Click on this image to see it bigger!) If you can, split the windows of your computer screen so that you can see both your Wolvden profile and your editor side-by-side.

Proceed to write to your heart's content. The editor conveniently auto-generates brackets for you and highlights critical errors such as misspellings or misplaced punctuation – features which are very helpful for cutting down on revision time. And as you write, be sure to hit Save at least once to see the instant feedback start taking place; this allows for your target page (in this case, your Wolvden profile) to start instantly reflecting your CSS changes as you type, hence why it is best to have both your editor and your profile page visible at once.

Stylus also lets you save these styles to your browser itself, so that you can pick up your coding projects again another day. However, I advise caution about relying on this feature; if you ever clean up your browser data or storage, this includes extension data, and Stylus's styles are part of that extension data to be wiped. To be extra safe I would advise backing up your CSS projects locally on your computer in plain text files in case your browser data is compromised.


*barks at you*
#202

Posted 2021-11-27 13:44:15 (edited)

KNOW YOUR SYNTAX

A CSS file consists of "blocks". A block (sometimes referred to as a rule) is a set of instructions enclosed by curly braces. This is the arrangement, or syntax, of a block:



The name appearing before the opening curly brace is the selector. Its job is to target an element on the page by its name, and so the following instructions within the braces will apply to that element.

Within the curly braces, instructions are declared. A single instruction targets a property of the element, and assigns a value to the property, changing the look of the element. A colon must separate the property and value, and a semicolon must come at the end of each value. Multiple instructions each belong on individual lines.

Read more about syntax: W3CSS, Mozilla, Tutorialspoint

VALIDATING SELECTORS WITH STYLUS

If you're using Stylus, here's a little exercise you can do to familiarize yourself with the various selectors.


Write this code into your Stylus window:



This is a simple block with a single instruction that gives its chosen element a thick red border. Hit Save and watch what part of your page adopts that red border; the example above should affect the page's top navigation bar.

You can go down the provided list and swap out selectors one by one, and as you do, keep note of what parts of the page are being affected. This way, you can visualize for yourself what such names actually represent, if the written descriptions are not as helpful for you.

I use this trick often in my own coding to check if I spelled the selector name right, or to locate a hard-to-find element. This is also useful for if you're selecting multiple elements at once and want to verify the collection of elements you're targeting.


FINDING SELECTORS WITH INSPECT ELEMENT

To become comfortable with web code, you ought to get comfortable with Inspect Element. It isn't mandatory, but knowledge of Inspect can greatly help you with troubleshooting an error, or obtaining unknown selector names, which will be explained in this pop-up section.


Inspect is a handy built-in tool most modern browsers let you access in just two clicks: right-click anywhere on a web page, and a small context menu should show up right next to where you right-clicked. The context menu should include a link labeled "Inspect" or "Inspect Element". Click on it, and your browser viewport will split between your current page and the Inspect panel.





A lot of information and code appears at once. It looks scary, but let's slow down and examine...



... the Elements tab. This section consists of the HTML "skeleton" of the entire page you are viewing. Notice that a particular line of this code is highlighted, this is the HTML of the element you right-clicked on.



The Inspect panel offers a quick and easy way of grabbing the selector name of whichever element you have selected. Simply right-click your desired element's code, and navigate through the context menus as shown in the above image.



In the above example, I selected the large header of my Welcome Back page, and when I paste the copied name into my Notepad, this is what it looks like. The selector names provided by Inspect are precise and often detailed, using child selectors to target the exact instance of the element you picked. You don't have to adhere strictly to what Inspect gives you; you can pare down the given selector name for something less intricate to reduce some confusion. As an example, here's what applying this trick to the sidebar chatbox header gives me:



This is pretty detailed, even for me. In this case, I would choose to omit child selectors entirely and keep only the first and last element names, like so:



Of course, it is good to test your selector names (see the popup section before this one!) to be sure of their validity. I tested both the above names out and they achieved virtually the same effect. If you find that editing the provided selector name does not work out, you should stick with the provided name.


*barks at you*
#202

Posted 2021-11-27 13:44:21
Reserved for guide text.

*barks at you*
#202

Posted 2021-11-27 13:44:27
Reserved for guide text.

*barks at you*
#202

Posted 2021-11-27 13:44:36
Reserved for guide text.

*barks at you*
#202

Posted 2021-11-27 13:44:46
Reserved for guide text.

*barks at you*
#202

Posted 2023-03-12 04:11:04
Omg thank you so muchhhh
(NOT ACTIVE)
#117544

Search Topic