Welcome to Code Forum!

Join a community that supports you and your coding journey from day one. We strive to be a friendly, supportive community that empowers everyone to be better developers. By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    GIF shows where to locate </> in the thread and or post editor toolbar.
    To learn more about how to use our BBCode feature, review our "How to post your code into threads" here.

    Thank you, Code Forum.

Using CSS classes in table

amd.64

Coder
I'm trying to use multiple classes in a table, although I am not combining them. I am using them at different parts of the table.

What I have is:

CSS
Code:
.objs {
    text-align: center;
    font-size: 18px;
    font-weight: bold;
}

.tables {
    text-align: center;   
}

HTML
Code:
<td class="tables">

<td class="course-title">

<td class="objs">

The only one I can get to work is the second one, class="course-title". The first one is nesting a table in a table. I want it centered, I have seen other forums and "how-to sites" say to do it the way I am, however the only way I can get the nested table centered is to use align="center". However HTML validators complain it is out of date, is it "ok" to use it. Is there a third option?
 
Post the full table layout please.

CSS:
.tables {
    text-align: center; 
}

HTML:
<table style="width:100%; border:hidden">
    <tr>
        <td style="text-align:right"></td>
    </tr>

    <tr>
        <td class="tables">
            <table style="width:62%; border:hidden">
                <tr>
                    <td class="course-title"></td>
                </tr>
                <tr>
                    <td class="objs-1"></td>
                  
                </tr>
                <tr>
                    <td class="objs-2">
                        <ul>
                            <li></li>
                            <li></li>
                            <li></li>
                            <li></li>
                        </ul>
                    </td>
                </tr>
            </table>
        </td>
    </tr>         
</table>

This is the HTML and CSS code for the nested tables including unordered list. I want to use the class "tables" to center the nest table.
 
Are you trying to get something like this?
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .main {
            width: 80%;
            position: relative;
            left: 10%;
            top: 20px;
            background-color: tan;
        }
        .inner-table {
            background-color: brown;
            margin: 0%;
            margin-left:auto;
            margin-right:auto;
        }

    </style>
</head>
<body>
    <table class="main">
        <tr style="background-color: salmon;">
            <td align="center">1st table row</td>
        </tr>
        <tr style="background-color: beige;">
            <td>
                <table class="inner-table">
                    <tr style="background-color: skyblue;">
                        <td>inner table 1st row</td>
                    </tr>
                    <tr style="background-color: hotpink;">
                        <td>inner table 2nd row</td>
                    </tr>
                    <tr style="background-color: gold;">
                        <td>
                            <ul>
                                <li>1</li>
                                <li>2</li>
                                <li>3</li>
                                <li>4</li>
                            </ul>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</body>
</html>
 

Attachments

  • Kazam_screenshot_00000.png
    Kazam_screenshot_00000.png
    13.3 KB · Views: 1
Sort of
I am trying to get this to work on multiple pages. I have provided a link to one of them
link

Other then the Linked in image and menu at the top all text that is justified left I want it centered, then justified left. In other words kid of like it would appear in word. Other wise the page is how I want it.
 

Buy us a coffee!

Buy me a coffee.
Back
Top Bottom