CSS3 > Selectors

ID selector in CSS3

How to specify CSS style for an element whose ID specified in CSS3?


ID selector is used to specify css style for an element whose id specified.

<style>
        #myId {
            background-color: Fuchsia;
            border: 1px solid #c0c0c0;
        }
</style>

<body>
    <div>This is Empty Div</div>
    <div id="myId">This is Div with ID</div>
    <div>This is Empty Div</div>
</body>

In the above code snippet we can notice that, there are three <div> tags. In that ID selector is applied to the 2nd <div> tag.

OUTPUT

 Views: 3760 | Post Order: 5



Write for us






Hosting Recommendations