SHARE
Facebook X Pinterest WhatsApp

HTMLGoodies Community Mentors: CSS FAQ

Written By
thumbnail
Vince Barnes
Vince Barnes
Jan 4, 2005


CSS Frequently Asked Questions


 

Design:

 

Q. 

I know how to
center tables in an HTML file regardless of the screen resolution of the
user but is there a way to center the layers (again regardless of the user
screen resolution)?

A. 

You will want to
position a layer using CSS and want the positioning to be in the middle of
the screen regardless of screen size. You can do that giving percentages
instead of pixels. Here is a sample code:

<HTML>
<HEAD>

<STYLE TYPE="TEXT/CSS">
<!–
div.test {position:absolute; top: 50%;right: 50%}
–>
</STYLE>
</HEAD>

<BODY BGCOLOR="#FFFFFF">

<DIV class="test">Test</DIV>

</BODY>
</HTML>
 

Hyperlinks:

 

Q. 

Is it possible to have 2
different Visited Link colors for links on different parts of a page, e.g. a
navigation bar different from the content?

A. 

Yes, it is possible to do this
with help of classes. Basically, you have to give class names (e.g. <A HREF="file.html"
class="content">Link Text</A>) to all your links. The links in the content
section should have class="content" and the links in the navigation bar
section should have class="nav". Then add these lines to your STYLE’s:

a.nav:visited {color: red;}
a.content:visited {color: green;}

Basically this ensures that the anchors with the nav class that are visited
will have a color of red and likewise for the content. You could also change
fonts and actually do everything that stylesheets allow.

If you have many links in your content section, make life easier for
yourself: Just add class="nav" to the navigation bar links and these two
lines, instead of the two above to the styles.

a.nav:visited {color: red;}
a:visited {color: green;}

This way ALL your links’ color will be green EXCEPT for those who are tagged
as nav.

 

Recommended for you...

Best JavaScript Frameworks & Libraries for Building Web Dashboards
Rob Gravelle
Jul 29, 2021
Google Web Vitals for Beginners
Diogo Souza
May 4, 2021
Web Site Maintainability
Vince Barnes
Jan 10, 2021
Getting Started with Grunt.js
Diogo Souza
Oct 8, 2018
HTML Goodies Logo

The original home of HTML tutorials. HTMLGoodies is a website dedicated to publishing tutorials that cover every aspect of being a web developer. We cover programming and web development tutorials on languages and technologies such as HTML, JavaScript, and CSS. In addition, our articles cover web frameworks like Angular and React.JS, as well as popular Content Management Systems (CMS) that include WordPress, Drupal, and Joomla. Website development platforms like Shopify, Squarespace, and Wix are also featured. Topics related to solid web design and Internet Marketing also find a home on HTMLGoodies, as we discuss UX/UI Design, Search Engine Optimization (SEO), and web dev best practices.

Property of TechnologyAdvice. © 2025 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.