CSS basic syntax

The CSS syntax is made up from three parts:  selector, property and value:

selector {property: value}
body {color: #ffffff}
  • The selector is normally the HTML element/tag you wish to define, like body
  • The property is the attribute you wish to change like color, and font
  • The value is the property value: #ffffff

HTML class tag

If you want to have paragraph (tag p) with right-aligned. You can write it like this:

HTML CODE

<p class="right">
Right-aligned.
</p>

CSS CODE

p.right {text-align: right}

You can also omit the tag name in the selector to define a style that will be used by all HTML elements that have a certain class. In the example below, all HTML elements with class=”right” will be right-aligned:

.right{text-align: right}

HTML ID tag

You can also define styles for HTML elements with the id selector. The id selector is defined as a # in css. 

HTML CODE

<p id="right">
Right-aligned.
</p>

CSS CODE

p#right { text-align: right }

Or

#right { text-align: right }

Related posts:

  1. Top US hosting
  2. Protecting your pages with htaccess
  3. How to calculate your website value
  4. johnchow.com Revenue Report
  5. How to preload your web image?

0 comment(s)

  • Any feedback from you?

    This site uses KeywordLuv. Enter YourName@YourKeywords in the Name field to take advantage.

Jun 19, 2008 by

Want to set up your own web server at home? Read this guide

Super Green Hosting HostGator GreenGeeks WP Web Host green web hosting ad