2014-12-31 46 views
-1

我是新來的HTML和CSS,我堅持使用外部CSS樣式的類..請指導我。這是迄今爲止我的html代碼:html:使用外部CSS的類

<!DOCTYPE html> 

<html> 

<head> 
<link ref="stylesheet" type="text/css" href="styles.css"/> 
</head> 

<body> 

<h1 class="ha">Welcome!!!</h1> 

<hr> 

<p class="style">welcome to our website!!!</p> 

</body> 

</html> 

這是我的外部CSS代碼:

h1.ha{color:blue;font-size:450%;text-allign:center;} 
p.style{color:red;font-size:250%;} 
+1

當你去理髮,他們問你想怎麼樣你會說「我只是想我的頭髮剪」? – PeeHaa

+2

你想實現什麼?問題是什麼?您必須更加具體... –

+0

究竟是什麼問題?它不工作嗎?或只是一些部分? – Vinc199789

回答

3

當鏈接到外部CSS使用:

<link rel="stylesheet" href="styles.css"/> <!-- You have "ref" instead of "rel" --> 

然後在您的styles.css文件:

.ha { 
    color: blue; 
    font-size: 45px; /* I recommend using px, or em/rem for sizing text (ex: 12px) */ 
    text-align: center; /* You had a typo */ 
} 

.style { 
    color: red; 
    font-size: 25px; /* Again, use px, em or rem for text sizing */ 
} 
+0

謝謝Vucko - 可能應該在我上面的例子中使用正確的評論。 – Justin

+0

非常感謝好友。它的工作 –

+0

樂於幫助。 SO對於開發者來說是一個很好的資源,當我遇到問題時,它始終是我的首選。在未來的發展中祝你好運!不要忘記將此答案標記爲您的解決方案。 – Justin

1

你有你的代碼中有兩個錯誤。更正是rel="stylesheet"text-align:center

+0

謝謝。它的工作 –

+0

Offtopic,但我也是14歲:) – TuomasK

+0

親愛的,我說他們是新的網絡發展,並給你驚喜,我已經開始了今天。我以前用VB.net,C++和C編程語言編程,是的,我很擅長...... TuomasK –