CSS Div Id Class
CSS Tutorial » CSS div id class
In the CSS to select elements class, write a "." (dot) character, followed by the name of the class
and an id selector is a name preceded by a "#" tag.
Syntax:
Syntax: id CSS.
Syntax: class CSS.
#id_name {
css declarations;
}
Syntax: class CSS.
.class_name {
css declarations;
}
Note: use external CSS instead.
Different Id / Class Although both #id and .class can be used to style an html element. In practice, only the class attribute is used for this purpose. The id attribute is generally used in javascript to locate an html element and perform actions on it.
On the other hand, the id attribute must be unique on the page. This means that there cannot be another html element with the same id. The presence of several elements with the same id, can generate javascript errors and invalid html copy.
How to create div CSS id and class - examples
You can try to execute the following code to change div CSS id and class property of a text on this page.
Example:
Example 1, How to create div CSS id and class property - examples:
<!DOCTYPE html>
<html>
<head>
<title>How to create div CSS id and class property - examples - example</title>
<style>
#first_box {
width: 380px;
border: 2px solid #00FF00;
text-align:right;
font-family: "Courier New", Courier, monospace;
font-size: 18px;
font-style: italic;
font-weight: bold;
color: #00CCFF;
text-decoration: none;
background-color: #CCCCCC;
}
.second_box { width: 276px;
text-align:left;
font-family: "Courier New", Courier, monospace;
font-size: 14px;
border: 2px solid #0000FF;
margin-top: 18px;
}
</style>
</head>
<body>
<div id="first_box"> <h1>How to create div CSS id and class property</h1> How to create div CSS id and class property - examples - example
<div class="second_box">How to create div CSS id and class property - examples - example.</div> </div>
<div class="second_box"> This div contains a very long word:
will break and wrap - thisisablablarylongwordblarylongwordblarylongwordblarylongwordblarylongword.
The long word will break and wrap to the next line.</div>
</body>
</html>
Note: Use external CSS instead.
css div id class, together, selector
CSS Div Id Class - css tutorial
Online Editor
This tool makes it easy to create, adjust, and experiment with custom colors for the web.
HTML 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

Find here examples of creative and unique website layouts.
Free CSS HTML Menu

Find here examples of creative and unique website CSS HTML menu.