PE: The Gate To CSS

19 min read

Deviation Actions

PizzaPotatoNBacon's avatar
Published:
5.9K Views


This article was written by PizzaPotatoNBacon for projecteducate's Community Week June 3rd - June 9th. This article is written to explain the basics of Journal Skin CSS Code- however it does not contain much information on the layout and structure of journal skins. Basic knowledge of HTML is needed to understand most of the article. Does not include information on Gallery CSS. And yes, you do have to have a bit of patience when it comes to coding. If a lazy bum like me can do it, so can you. :stare:

 

Hola! :hoLA:

   Today, I'll be talking about CSS and how it works. This article is intended for newcomers and beginners, and only explains how it works, and how it "happens". From the syntax to the basic codes, from examples to links, this article that I had spent sleepless nights on is for you! I hope the information and explanations within this publication is easy to understand. If you have any questions regarding basic CSS, feel free to ask me. :nod:


 

:bademoticon:Index for easy navigation


 

:wave: An small introduction to CSS (No interesting Biographies Included)


  As we all know, most web pages get some or all of their formatting from a good ol' Hypertext Markup Language code. It's pretty much common knowledge that a <b></b> tag makes text bold, an <i></i> tag makes text italic, and so on. However, in many sites, the HTML itself is styled to look sexeh. That's all thanks to CSS.

 

   One way to describe CSS and HTML and a web page, it's like a puppet. HTML is the puppeteer, and the web page is the puppet. However, CSS is like the clothing on the puppet- it stylises HTML, gives them a bit more flair and consistency. Another way to describe it, is that the HTML is a director. It tells the web page (Actor) what to do. And CSS, being the stylising code it is, is the Make Up Artist. HTML may control what's on your page, but CSS makes it look pretty and sparkly. This is a subjective description, but you catch my drift.


:? How does it work with deviantART Journal Skins, then?

 
Back to Index

   All members of deviantART can use HTML in their journal entries- and you can stylize that HTML with a journal skin CSS! Unfortunately, while everyone can use [certain] HTML in their entries, they cannot have the HTML stylised by Journal Skins. The site manages to turn your code into installable skin- not sure if it's magic or just some bad*ss programming by the awesome dA staff- for others to enjoy. But how does CSS work in the skin itself?


   Let's go back to the puppeteer theory. Now, imagine two kinds of puppeteers. One has lots and lots of accessories and dresses for their puppet, and the other has a limited amount of clothes for their puppet. The same applies to Journal Skin CSS. In Journal Skins, some things can't be applied to your HTML elements when they can in site-wide CSS.

 

   Why am I putting this here? This is just a bit of a forewarning- that any neat code you find [outside of a deviantART Journal skin tutorial] may not work. Of course, this shouldn't be that much of a problem. Remember, limitation prompts creativity! Don't be afraid to tweak things around and break barriers- getting out of that shell is something we all love to do! :la:

 

:dummy: Jumping Into The Realm: Learn the lingo, and love the language

Back to Index

Terms:

  • Element - In HTML, this is the content/effect/container formatted with its respective HTML tag.
  • Declaration - In CSS, this a string of code that contains a property, and a value, that will modify your HTML elements and parts of your journal skin. Example:
    b {
    property:value
    }
  • Property - This is a certain setting of an element- a property (thus it is named so) of the element. What do I mean by this? Here is an example:
    b  {
    height: - This tells the browser what property of the element are we going to modify. In this case, it is the height of the element.
    }
  • Value - This is how the setting is changed. Default skins have certain settings, so when you create a journal skin, you must declare a value for properties of an element, otherwise things will stay the same. :stare:
    b {
    height: 10px; - This tells the browser the "value" of your property. Values can range from color codes to equations- it depends on the property itself. SInce the property is the height of the element, I'm making the height of "b" 10px.
    }
  • [Magic] Curly Brackets [of fairy sparkles] - These babies: {}.  Your modifying code goes in between these. :eyes: 
    { - This is the opening bracket. It goes right after your element, and right before your first declaration.
    height: 10px;
    } - This is the closing bracket. Once you're done with your code, close it with this hotshot.
  • Comments - CSS comments are text that are in the code but don't affect it in anyway. These are text within /* */'s and they can be used for notes on the code, labels, extra code to be used later.
     /* This is a Comment Hurr durr */
     
    b {
    height: 10px;
    } Take note that, in deviantART CSS, one cannot put a comment in between declarations and Curly Brackets.

CSS Syntax

element {
property: value;
}

Here is a bit of a walkthrough when constructing the code for an element.

1. Let's specify an element to modified.
element {}

Let's use <h1> as our example element.
h1 {} <-- Easy-peasy, lemon-squeezy.

2. Okay, we've got our element. Time to give it basic features like a background, text color, and a border.
element {
property: value;
property: value;
property: value;
}

h1 {
background: #fff; <-- We're altering the background of the element here. Pretty obvious, no? :D That "#fff" is the hex code for the color white. 
color: #000; <--  Here, we're setting the text color to #000, which is hex color code for black. 
border: 2px solid #000; <-- This Property's syntax is (thickness of border line) (type of border line- solid, dashed, or dotted) (the color of your border).
}

3. Goodie-goodie! Let's add margin and padding! :la:
element {property: value;
property: value;
property: value;
property: value;
property: value;
}

h1 {
background: #fff;
color: #000;
border: 2px solid #000;
margin: 20px; <-- This is the space between your element and all other elements around it.
padding: 5px; <-- This is the space between the border of your element, and your element's actual content.
}

And this is what we get:


This is the effect!

Do you get how it works now? :la: It's all about specifying and giving commands by the means of code. :bademoticon: Rather simple syntax, no? :D
 

:confused: Basic, but important!


Basic Properties


  • background - Obviously, it changes the background of your div. This can be an image, color, or even a gradient! The syntax for "background" is  background: url('directlinkhere')|color|#00000|(r,g,b,a);. You can have both image and color in the background.

  • color-  This affects the text color within your div. The syntax for "color" is color: color|#00000|(r,g,b,a);.

  • border - This is the border of your div. You can modify all or specific sides of the border by using these properties: border-left (modifies the left side), border-right (modifies the right side), border-top (modifies the top), and border-bottom (modifies the bottom). The syntax for "border" is border: 0px solid|dashed|dotted color|#00000|(r,g,b,a);.

  • margin - This is the space between your element/div and other elements. You can apply margin to all sides, or to specific sides, similar to "border". Use the properties margin-left, margin-right, margin-top, and margin-bottom to modify left margin, right margin, top margin, and bottom margin, respectively. The syntax for "margin" is margin: 0px|0%|auto;

  • padding - This is the space between the border of your div and your div's content.  You can apply padding to all sides, or to specific sides, similar to "border". Use the properties padding-left, padding-right, padding-top, and padding-bottom to modify left padding, right padding, top padding, and bottom padding, respectively. The syntax for "padding" is padding: 0px|0%|auto;

   If you notice, many journal skins modify normal HTML elements to fit the rest of the skin itself, so it's important that, in the case they don't look right with your skin, you must still modify the Standard HTML elements. Here is a list of "basic" HTML elements modifiable for Journal Skins. 

b {}, strong {} - Technically they yield the same effect. A good way to make use of this fact is by making slightly different versions of the same effect by modifying one or the other. Perhaps <b> yields a green bold text in your skin, whereas <strong> yields a blue bold text on your skin.
i {}, em {} - The same case as <b>bold</b> and <strong>. Both yield the same effect.
u, ins {} - Nearly the same case as <b>bold</b> and <strong>. Both yield almost the same effect. 
strike {}
p {}
blockquote {}
sup {}
sub {}
small {}
.abbr {}
acronym
hr {} - Yes, you can style your horizontal lines.
code{}
tt {}
h1 {} to h6 {} - Take note that the selector for h2 should be .text h2 {} so you won't affect the journal title.

But that's not all!

   We can create our own "elements", these are called "divs". This can be anything, really- from a new kind of text style similar to bold, italic, underline, to a fancy text container. From just images, to shapes. We can use the HTML elements we create to make works of art! :la: And the process is very, very simple.


CSS

.papaya - We create our own HTML element via CSS, by placing a "." then your element/div class name. That's it. Just that. Then put in all that sexy code.

.papaya {

property:value;

}

HTML

Read the description of this article for the HTML code.


Effect

Look! A fancy class~

Since it is not an "real" HTML element, we have to specify which div we're using by using <div class="divclassname"></div>.

   

I just want to put this out here. Did you know you can modify elements within elements?You can modify what happens when one element/div is placed within another element/div. What magic happens when a <b tag is placed outside or inside a <p> tag? With CSS, you can do more with <p><b> than just make bold letters inside a <p> tag. This is also effective for making custom HTML easier for users of your skin, as explained in this lovely article written by no other than gillianivyart. There are more reasons why this is very, very important, such as your normal header blending in with the background of a custom div, maybe it's too big for that div.


:book Resources, Resources everywhere

Back to Index

Here are some fabulous resources, should you want to know more about CSS. :nod:

Tutorials and Resources

This tutorial is certainly a powerhouse. It is very comprehensive yet it is extremely understandable. With coverage on the basics, and lovely snippets, this is definitely worth a look. :dummy:

This nifty tutorial does a good job of explaining Journal Skin Structure. :la:

This is really worth a read, since it explains a whole lot of CSS terms and codes. :nod:

:thumb354675797:

This article is very good at explaining the structure of Journal Skins and basic CSS codes. It provides snippets and guides you through the process of making your own Journal Skin! :la: Very, very good resource for those new to CSS.

PE: CSS3 101 - Introduction

Hey there Devious CSSkinners! :wave:
First off, hover over the Title and Stamp to see some snazzy effects. That's the kind of stuff that CSS3 allows users to play around with. As I had been an Alpha Tester on :devdevbug:, we had a few CSS3 privileges to test in Journal Skins in which several deviants had asked me "How did you do that?" and "Please share the code so we can learn" so I've been meaning to give a few lessons on CSS3 since forever and projecteducate has given me the opportunity to do so :meow:
These are the Topics that will be covered this week:
May 27th - Introduction
May 28th - Color Gradients
May 30th - Pseudo-elements & Pseudo-Classes
May 31st - Transition Animations
June 2nd - Conclusion
I'll try to be as simple as possibl

Last Week, projecteducate hosted a CSS3 week! The articles in these week are very comprehensive, and can help make your CSS more sexy. :datass: 

 

Groups

:iconecssited: 

This group is dedicated to helping other improve or learn CSS skills. They collect everything CSS from tutorials to snippets, from CSS events announcements, to resources. This is a great place for all your [deviantART] CSS needs.

:iconcss-dyk:

Did you know? ...That there's a group dedicated to sharing various CSS tips and tricks, by the means of comprehensive yet fully understandable articles? Check out CSS-DYK, made for those who'd like to do more with their CSS. Read excellent articles, and suggest topics for the next issue!


External References

w3schools.com - A lot of articles on CSS and good explanations. Highly recommended for beginners.

Css-tricks.com - Find neat tricks to use in your CSS! This site has a lot of snippets for you to use for your code, so it's worth a look at. ;D

Cssdesk.com - Got a snippet you want to try out? How about a little bit of live CSS practice? Are you sure there's nothing wrong with your code? Try css-desk! A fabulous way to try out your CSS codes and have them brought to life. :nod:


:heart: That's all folks!

That's all I can fit into this article! While CSS is tough to get a hold of at first, but with a lot of practice, it's very easy to understand and code. If you have more questions about CSS, feel free to comment and ask me. Please note that I am not the best, however, and I don't guarantee I'd know the answer to your question, or the question to your answer. :8Bnod:

 

Thanks for reading, and have a nice day! :wave:

:heart:, PizzaPotatoNBacon





© 2013 - 2024 PizzaPotatoNBacon
Comments36
Join the community to add your comment. Already a deviant? Log In
HollyKBear's avatar
:star::star::star::star: Overall
:star::star::star::star::star-empty: Vision
:star::star::star::star::star-empty: Originality
:star::star::star::star::star: Technique
:star::star::star::star::star-empty: Impact

This was a little hard to follow along to, but all I needed to do was read it another time to get it. Grate idea using other things to compare to the CSS and HTML. It really helped. I think its kind of hard to understand all the letters at once. Maybe giving a name for CSS and HTML will help us tell the difference. Other than that this was really helpful. Thank you very much!

PS: Your so smart I would have never been able to figure this out without your help. It was so confusing like my head would have popped off -@