CSS Syntax
CSS Syntax
CSS Syntax
CSS Selectors
CSS selectors are used to "find" (or select) HTML elements based on their element name, id,
class, attribute, and more.
The id Selector
The id selector uses the id attribute of an HTML element to select a specific element.
The id of an element should be unique within a page, so 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.
Example
#para1 {
text-align: center;
color: red;
}
To select elements with a specific class, write a period (.) character, followed by the name
of the class.
In the example below, all HTML elements with class="center" will be red and center-
aligned:
Example
.center {
text-align: center;
color: red;
}
CSS Comments
Comments are used to explain the code, and may help when you edit the
source code at a later date.
External CSS
Inline CSS
An inline CSS is used to apply a unique style to a single HTML element.
This example sets the text color of the <h1> element to blue:
Internal CSS
An internal CSS is used to define a style for a single HTML page.
External CSS
An external style sheet is used to define the style for many HTML pages.
Property Description
unicode-bidi Used together with the direction property to set or return whether
should be overridden to support multiple languages in the same docu
Easy to use: Anybody with just basic knowledge of HTML and CSS can
start using Bootstrap
Responsive features: Bootstrap's responsive CSS adjusts to phones,
tablets, and desktops
Mobile-first approach: In Bootstrap 3, mobile-first styles are part of the
core framework
Browser compatibility: Bootstrap is compatible with all modern
browsers (Chrome, Firefox, Internet Explorer, Edge, Safari, and Opera)
Thumbnail
The .img-thumbnail class shapes the image to a thumbnail:
Responsive Images
Images come in all sizes. So do screens. Responsive images automatically
adjust to fit the size of the screen.
Create responsive images by adding an .img-responsive class to
the <img> tag. The image will then scale nicely to the parent element.
The .img-responsive class applies display: block; and max-width:
100%; and height: auto; to the image:
Bootstrap Basic Table
A basic Bootstrap table has a light padding and only horizontal dividers.
The .table class adds basic styling to a table
Striped Rows
The .table-striped class adds zebra-stripes to a table:
Bordered Table
The .table-bordered class adds borders on all sides of the table and cells:
Hover Rows
The .table-hover class adds a hover effect (grey background color) on table
rows:
Condensed Table
The .table-condensed class makes a table more compact by cutting cell
padding in half:
Contextual Classes
Contextual classes can be used to color table rows (<tr>) or table cells (<td>):
Responsive Tables
The .table-responsive class creates a responsive table. The table will then
scroll horizontally on small devices (under 768px). When viewing on anything
larger than 768px wide, there is no difference:
<h1> - <h6>
By default, Bootstrap will style the HTML headings (<h1> to <h6>) in the
following way:
<small>
In Bootstrap the HTML <small> element is used to create a lighter, secondary
text in any heading
<mark>
Bootstrap will style the HTML <mark> element in the following way:
<abbr>
Bootstrap will style the HTML <abbr> element in the following way:
<blockquote>
Bootstrap will style the HTML <blockquote> element in the following way:
<dl>
Bootstrap will style the HTML <dl> element in the following way:
<code>
Bootstrap will style the HTML <code> element in the following way: