# Subscript in HTML



## yes.fareed (Mar 17, 2011)

Hi,

I would like to know, is there any way to control "subscript" in HTML.

I would like to add a subscript(<sub>) to heading(<h1>) but would like to change its font & color etc.

<html>
<body style="background-color:lightGreen;">
<h1 style="font-family:Chiller;color:Red;font-size:80px;text-align:center">Mylapally Ravi Kumar<sub style="font-family:veranda;color:blue;font-size:20px>Neene Raju</sub></h1>
<hr />

<img src="https://lh4.googleusercontent.com/_qFTL5hCj8g0/TXfgGSADISI/AAAAAAAAEyA/lSAFVJpFBE4/IMG0159A.jpg"
</body>
</html>

I tried this way but never worked!

Thanks,
Fareed


----------



## Laxer (Dec 28, 2010)

Can't say i have ever used a sub.

perhaps a span would work, personally i would make it an h1 and an h3...


----------



## yes.fareed (Mar 17, 2011)

*Re: Subscript in HTML (Solved)*

Thanks a ton,

But I got the solution, All we need to do is to us "HTML Class Attribute".

<html>
<head>
<style type="text/css">
sub.fame {color:#0000ff;font-family:chiller;font-size:50px}
</style>
</head>

<body style="background-color:lightGreen;">
<h1 style="font-family:Chiller;color:Red;font-size:100px;text-align:center">Mylapally Ravi Kumar<sub class="fame">Neene Raju</h1>
<hr />
<img src="https://lh4.googleusercontent.com/_qFTL5hCj8g0/TXfgGSADISI/AAAAAAAAEyA/lSAFVJpFBE4/IMG0159A.jpg"
</body>
</html>

Thanks,
Fareed.


----------



## Laxer (Dec 28, 2010)

Remember to close your tags 

Personally i would have done:


```
<html>
<head>
<style type="text/css">
.fame {color:#0000ff;font-family:chiller;font-size:50px}
</style>
</head>

<body style="background-color:lightGreen;">
<h1 style="font-family:Chiller;color:Red;font-size:100px;text-align:center">Mylapally Ravi Kumar<span class="fame">Neene Raju</span></h1>
<hr />
<img src="https://lh4.googleusercontent.com/_qFTL5hCj8g0/TXfgGSADISI/AAAAAAAAEyA/lSAFVJpFBE4/IMG0159A.jpg"
</body>
</html>
```


----------



## yes.fareed (Mar 17, 2011)

Hi,

I'm afraid that u never used subscript!

Thanks,
Fareed


----------



## Rauny (Mar 24, 2011)

Hello mate this is very nice thread. Thanks for sharing such nice information. Take care.


----------



## DDAoN (Mar 19, 2011)

I know you've already figured a way around the issue, but I feel obligated to let you know what your problem was. The need for a class attribute doesn't exist. Only one thing kept you from having it work, you never put a closing " for the style attribute of the <sub> tag. In essence, everything after the start of the style attribute was considered part of it, until the first quote of the src attribute of the <img> tag. That didn't show up simply because you hadn't properly closed it either.

Here's what your original could would've been:

```
<html>
 <body style="background-color:lightGreen;">
  <h1 style="font-family:Chiller;color:Red;font-size:80px;text-align:center">Mylapally Ravi Kumar<sub style="font-family:veranda;color:blue;font-size:20px;">Neene Raju</sub></h1>
  <hr />
  <img src="https://lh4.googleusercontent.com/_qFTL5hCj8g0/TXfgGSADISI/AAAAAAAAEyA/lSAFVJpFBE4/IMG0159A.jpg">
 </body>
</html>
```
I hope this helps. Just keep an eye open in the code where a problem appears for something not written properly. ^^


----------



## Laxer (Dec 28, 2010)

Thought i would jump in one last time.

I will apologize ahead of time as a didn't quite understand that by subscript you actually wanted subscript....

anyway here is my solution:


```
<html>
<head>
<style type="text/css">
h1{
font-family:Chiller;
color:Red;
font-size:100px;
text-align:center
}
h1 sub {
color:#0000ff;
font-family:chiller;
font-size:50px;
}
</style>
</head>

<body style="background-color:lightGreen;">
<h1>Mylapally Ravi Kumar<sub>Neene Raju</sub></h1>
<hr />
<img src="https://lh4.googleusercontent.com/_qFTL5hCj8g0/TXfgGSADISI/AAAAAAAAEyA/lSAFVJpFBE4/IMG0159A.jpg" alt="This is an Image"/>
</body>
</html>
```


----------



## yes.fareed (Mar 17, 2011)

@DDAoN
Excellent dude!

I tried it earlier but there was a mistake(Check the original post) thus i went for class. And now I'm glad that i do not need to use class.

Thanks,
Fareed


----------



## yes.fareed (Mar 17, 2011)

I'm glad that TSF is a good platform for doubts & solutions.

I appreciate your zeal to spread the knowledge.

Laxer rocks! DDAoN Rocks!! TSF Rocks!!!!!

Lets close this here.



Laxer said:


> Thought i would jump in one last time.
> 
> I will apologize ahead of time as a didn't quite understand that by subscript you actually wanted subscript....
> 
> ...


----------



## DDAoN (Mar 19, 2011)

lol, I'm not a big fan of CSS, imbedded or otherwise. However, with websites as complex as I program, I'm glad it even exists, and I'm glad I could help.

As you develop your programming knowledge you'll come to appreciate the benefits of CSS and the attributes in a tag commonly associated with it. ^^


----------



## Laxer (Dec 28, 2010)

DDAoN said:


> lol, I'm not a big fan of CSS, imbedded or otherwise. However, with websites as complex as I program, I'm glad it even exists, and I'm glad I could help.
> 
> As you develop your programming knowledge you'll come to appreciate the benefits of CSS and the attributes in a tag commonly associated with it. ^^


I manage a 1000+ page website for my school.... without css i would be... :4-thatsba

Anyway always glad to help, please post another thread if you need anymore help.


----------

