Advertisement
Tech

Web Design Fundamentals: Basic CSS Code

Looking for a good place to learn the CSS basics? Check out this article. CSS is very simple to use once you get it down. Becoming a master at CSS requires that you learn some basic structure. From there, all you have to do is remember certain codes.

By Nicholas
Desk Tech
Reading time 3 min read
Word count 569
Web development Internet Css help
Web Design Fundamentals: Basic CSS Code
Advertisement
Quick Take

Looking for a good place to learn the CSS basics? Check out this article. CSS is very simple to use once you get it down. Becoming a master at CSS requires that you learn some basic structure. From there, all you have to do is remember certain codes.

On this page

CSS

CSS is actually one of the easiest coding languages to learn. CSS, or cascading style sheets, are what control the styling behind webpages. Below, you will learn about the basic structure of CSS and be able to view some working examples that will demonstrate the use of tags and attributes.

CSS Structure

Basic CSS code is implemented in one of two ways, directly or indirectly. Direct CSS implementation involves writing the CSS within the same page as the code (HTML ). Indirect or external CSS implementation involves writing the CSS on a separate style sheet and calling the style sheet to the code (HTML). Certain limited CSS styles can also be applied using tags around text. Below are some structure examples to give you a better understanding.

Advertisement

Direct CSS

Direct basic CSS code (CSS on the same page as HTML) looks like this:

Advertisement

This is a Title headline

This is sample paragraph

Advertisement

Notice how both the CSS and the HTML is contained within the div.

The first part,

inserts a background image. But it also uses CSS to define the height, width, and margins for the background image. Most importantly, it starts a div.

Advertisement

The second part,

This is a Title headline

inserts the text “This is a Title headline”. But it also uses CSS to define the text color, line-height, and padding. <h1 style=" opens an element, and closes it.

The 3rd part,

This is sample paragraph

Advertisement
inserts a paragraph containing the text “This is sample paragraph”. But it also uses CSS to define the text color of the paragraph and padding. <p style=" opens the paragraph and closes the paragraph.

Finally, at the very end, there is a

which closes the original <div style=".

Indirect CSS

Indirect basic CSS code (calling the CSS style sheet to the HTML) looks like this:

Advertisement

This is the HTML:

this is just some text

Advertisement

This is the separate CSS

#brighthub {

Advertisement

color:#006699;

font-size:15px;

Advertisement

font-weight:bold;

}

Advertisement

Notice that the HTML and CSS are completely separate.The “#” is used to define the div. You can also use a “.” rather than the “#”. The brackets { } hold the actual styling elements. Note that each element, such as color:#006699; ends in a ; which is used to the different style attributes.

This style of CSS is common in many content management systems, such as WordPress .

Advertisement

Direct Limited CSS Tags

There are certain tags that can directly style any text, as long as it’s HTML enabled and writable. For example:

will directly underline a piece of text. is the opening tag, and is the closing tag.

Advertisement

Bla bla bla = Bla bla bla (Check Using CSS Underline for more on that)

will directly bold a piece of text. is the opening tag, and is the closing tag.

Advertisement

Bla bla bla = Bla bla bla

will directly italicize a piece of text. is the opening tag, and is the closing tag.

Bla bla bla = Bla bla bla

Stylings

Now that you know how to use the three basic structures of CSS implementation, you can start to memorize the attributes and stylings. You can find a complete list of them here . That’s all there is to learning basic CSS code. Again, once you have the three basic structures down, you have basic CSS down. You can always refer to the stylesheet for the actual styles, as remembering them all can be difficult.

Keep Exploring

More from Tech

Filed under
Web development Internet
More topics
Css help
Advertisement