AgerNic.com
WEB DEVELOPER SITE, HTML, CSS, PHP, SQL

Basic Syntax of CSS - How to Code CSS

A CSS comprises of style rules that are interpreted by the browser and then applied to the corresponding elements in your document. A style rule is made of three parts: a selector, a property, and a value. CSS selectors are used to find HTML elements based on their element name as: id, class, attribute, and more.

autocar

The element Selector

The element selector selects elements based on the element name.
You can select all <h1> elements on a page like this (all elements will be left-aligned, with a green text color).

Example:
h1 {
text-align: left;
color: green;
}

The id Selector

The id selector is used to select one unique element! To select an element with a specific id, write a hash (#) character, followed by the id of the element. The style rule will be applied to the HTML element with id="unika", (in this case, #unika element will be height: 200px with a green background-color and 14 px font-size):

Example:
#unika {
height: 200px;
background-color: green;
font-size: 14px;
}

The class Selector

All the elements having that class will be formatted according to the defined rule. To select elements with a specific class, write a dot . character, followed by the name of the class. The style rule will be applied to the HTML element with class="box1", (in this case, box1 element will be height: 200px with a green background-color and 14 px font-size):

Example:
.box1 {
height: 200px;
background-color: green;
font-size: 14px;
}

Grouping Selectors

You can apply a style to many selectors how you like. Just separate the selectors with a comma as in the examples above.

Example:
h1, h2, h3, h4 { color: blue }

OK, so you've now learned about the CSS style syntax, but how do you incorporate this syntax into your website? The next lesson will show you how to incorporate CSS into your HTML webpage.


Syntax of CSS, How to Code CSS, Basic CSS
Basic Syntax of CSS - How to Code CSS - css tutorial

Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.


CSS Scrollbar Horizontal
CSS Scrollbar in Div
CSS Scrollbar Firefox
CSS Style Scrollbar
CSS Style Text
CSS background color
CSS Div Id Class
CSS Text Wrap
CSS text-align
CSS Text Decoration
CSS Text Shadow
CSS Text Color
CSS Text Bold
CSS Text Size
CSS background image full
CSS background opacity
CSS border radius
CSS rounded corners
CSS font color
CSS Class & ID
CSS align image center
CSS align content
CSS link color
CSS Text Style
CSS Text Font Size
CSS max width &height
CSS width and height
CSS Margin
CSS Padding
CSS Border Style
CSS background
CSS in HTML
Basic Syntax of CSS
CSS Introduction
Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.


Upload Image, display, edit and delete i...
Login Form with Image background...
How to Create an Image with Transparent ...
Portfolio Gallery Website with filtering...
Simple pagination script PHP MySQLi...
Center Image in div...
Image Hover Overlay Fade...
Sticky image / element / div on scroll...
Responsive images...
Create rounded image in HTML CSS...
Add border around image...
Position Text Over an Image HTML CSS res...
Create a Slideshow Images Gallery...
Create a Sticky Sidebar...
Search bar using CSS HTML...
Shrink Navigation Menu on Scroll...
How to Create Accordion HTML Templates...
Dropdown menu in the navigation bar...
Responsive Top Navigation Bar with mobil...
Split horizontal navigation bar...