position span inside a table cell by class or id

Posted on 2016-10-20
Last Modified: 2016-10-21
If i have a html table with id of mytable and inside of this table i have a table cell with class colstyle 2. In this table cell I have 2 spans.
One span has a class of span1class and the other one has a class of span2class

If I use this css statement it positions both of my spans on the top right

        #mytable td.colstyle2 span {
            position: absolute;
            top: 1px;
            right: 1px;

How would my statement look if I only want the statement to apply to the span with class span1class ?
Question by:maqskywalker
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2

Expert Comment

by:Amita Singh
ID: 41853289
please share your html code or link.

Author Comment

ID: 41853930
Hi here is a fiddle of my example.

Notice how the span containing "Howdy"  and the span containing "Hello" are both being put on the top right.

I only want the span with class Peach containing "Hello"  to be put on the top right.

My desired result should look like this:

desired result
So in my fiddle. This span with and it's hyperlink are the only thing I want put on the top right corner:

                                    <a href="">
                                        <span title="My Second Span" class="PeachClass" id="TestSpan2">

Accepted Solution

Amita Singh earned 500 total points
ID: 41854242
add this css
#mytable td.colstyle2 span#TestSpan2 {
    position: absolute;
    right: 1px;
    top: 1px;

Open in new window


Author Closing Comment

ID: 41854363
Perfect. Thanks.

Expert Comment

by:Amita Singh
ID: 41854372
You Welcome

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question