CSS - Id and Class

Class Id and the selector

If we want to set CSS styles in HTML elements, then we need to set the "Id" and "Class" selector in the element.

Id selector

Id selector may Id labeled specific HTML element specifying a particular style.

HTML elements are provided Id Id attribute selector, CSS selectors Id to the "#" is defined.

The following rules apply to the style element property Id = "Para1":

#Para1
{
    text-align:center;
    color:red;      
}

 Note: Id try not to use numbers beginning, Id start with a number does not work in some browsers.

Class selectors

Style selector is used to describe a class group of elements, different from the class selector id selector, class selector may be used in a plurality of elements.

class selector to represent the class attribute in the HTML, in the CSS class selector to display a dot, for example. "":

.center {text-align:center;}

We can also specify a particular HTML element to use class.

In the following examples, all the p elements using class = "center" so that the text of the element Center:

p.center {text-align:center;}

Note: The kind of, in the name of the class, do not use starts with a number, because the number at the beginning of class, some browsers do not support.

  Author: Jeremy.Wu
  Source: https://www.cnblogs.com/jeremywucnblog/
  This article belongs to the author and blog Park total, welcome to reprint, but without the author's consent declared by this section must be retained, and given the apparent position of the article page the original connection, otherwise the right to pursue legal responsibilities.

Guess you like

Origin www.cnblogs.com/jeremywucnblog/p/12118181.html