CSS Element Selector is a straightforward CSS selector that uses the name of any HTML element as a selector for applying the CSS styles on those elements.



Syntax:

html_tag{
/* declarations */
}

Below is an example of a element selector implemented on paragraphs:

CSS Element Selector Example

Example:

<!DOCTYPE html>
<html>

    <head>
        <style>
            p { font-family: Arial, Helvetica, sans-serif; font-size:14px; color:#666699; } 
        </style>
    </head>

    <body>
        <p>The CSS style will get implemented in every paragraph element.</p>
        <p id="para1">This paragraph will also get affected.</p>
        <p>And This one will also get affected as element selector is set for 'p' i.e. all paragraph.</p>
    </body>

</html>

In the above example, the CSS Element selector has been applied to the HTML paragraph element. And all the paragraphs are being affected.



Found This Page Useful? Share It!
Get the Latest Tutorials and Updates
Join us on Telegram