Programming in HTML5 with JavaScript and CSS3 — Question 16
Which CSS3 code fragment will style only the external links in an HTML document?
Answer options
- A. a: visitied { font-weight: bold; }
- B. a [href$= "http://"] { font-weight : bold; }
- C. a {font-weight: bold; }
- D. a [href^= "http://"] { font-weight : bold; }
Correct answer: D
Explanation
The correct answer, D, targets links that start with 'http://' which are typically external links. Option A is incorrect because 'visitied' is a typo and does not apply to any links. Option B uses '$=' which matches links that end with 'http://', not the beginning, making it less effective for external links. Option C applies to all links, not just external ones.