07. Using ID

3 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
This is a free item
$0.00
د.إ0.00
Kz0.00
ARS$0.00
A$0.00
৳0.00
Лв0.00
Bs0.00
B$0.00
P0.00
CA$0.00
CHF 0.00
CLP$0.00
CN¥0.00
COP$0.00
₡0.00
Kč0.00
DKK kr0.00
RD$0.00
DA0.00
E£0.00
ብር0.00
€0.00
FJ$0.00
£0.00
Q0.00
GY$0.00
HK$0.00
L0.00
Ft0.00
₪0.00
₹0.00
ISK kr0.00
¥0.00
KSh0.00
₩0.00
DH0.00
L0.00
ден0.00
MOP$0.00
MX$0.00
RM0.00
N$0.00
₦0.00
C$0.00
NOK kr0.00
रु0.00
NZ$0.00
S/0.00
K0.00
₱0.00
₨0.00
zł0.00
₲0.00
L0.00
QR0.00
SAR0.00
SEK kr0.00
S$0.00
฿0.00
₺0.00
$U0.00
R0.00
ZK0.00
Already have an account? Log In

Transcript

In this session, let us learn how to give unique formatting to HTML elements. Already we have learned that using inline CSS this can be done. For this, you have to use the style attribute. Now we are going to learn how to use the ID and ID attribute of HTML to apply unique formatting. For using the ID attribute in CSS, you need to go in for this hash. When you want to apply the same formatting to different elements going for class attribute, if you want to apply unique formatting to a particular HTML element going for this hash attribute, how to apply I mean going for this ID attribute how to use it, use it this hash.

Let us see the usage of it using an example. I have an HTML page with two p tags and two h1 tags. One p type is having an IDS my ID one h one is having IDs hit that. Now, let me first apply the skiving for p tag separately h1 tag separately then let me go in for the ID part. So, here P as usually is going for background only 40 The background is yellow for h1 let me give the background as green. Next let me use the ID attribute.

So, I have to go in for hash my ID. Now, I can change the color background text color. So I can change whatever properties I want. So here it is again font size 20 pixels Okay, this is for p tag. I mean p tag my Add so which one will change only the content within nine number 24 will change. Same thing I can do it for header.

For header let me add a border also border color, border width. And also I can just go in for text turning. Okay. Again going for font weight, bold, okay, so you can just try adding different types of CSS properties. The idea over here is how to use this. Now let me save this.

Let me right click open in browser. IDE minimize this. Now I have a browser and the Sublime Text is basic. Let us examine the output, the background color for the p tag this yellow and the tag p tag which is having IDs my ID has got the color of red the text is aligned to center and the font size increase to 20 pixels coming to the header part. For h1, the background is green. So both are showing the background as three.

What about the border color? The border color is not shown for has faded. For the second one it has to show the border right. It is not showing me the border. Let me check it out. Yeah, I forgot to add the border style.

Border site stays solid, that is solid dotted. Whatever you see in Microsoft work, the same stuff is available over here a CSS also I have added a solid that will refresh now. Now I have got the output. So with ID you can give unique property unique formatting to HTML element. That's it. Thank you.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.